Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions common/utils/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -5099,11 +5099,6 @@
"Unrecognized Parquet type: <field>."
]
},
"_LEGACY_ERROR_TEMP_1175" : {
"message" : [
"Unsupported data type <dataType>."
]
},
"_LEGACY_ERROR_TEMP_1181" : {
"message" : [
"Stream-stream join without equality predicate is not supported."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1908,8 +1908,9 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def cannotConvertDataTypeToParquetTypeError(field: StructField): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1175",
messageParameters = Map("dataType" -> field.dataType.catalogString))
errorClass = "INTERNAL_ERROR",
messageParameters = Map("message" ->
s"Cannot convert Spark data type ${toSQLType(field.dataType)} to any Parquet type."))
}

def incompatibleViewSchemaChangeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.spark.sql._
import org.apache.spark.sql.api.java.{UDF1, UDF2, UDF23Test}
import org.apache.spark.sql.catalyst.expressions.{Coalesce, Literal, UnsafeRow}
import org.apache.spark.sql.catalyst.parser.ParseException
import org.apache.spark.sql.execution.datasources.parquet.SparkToParquetSchemaConverter
import org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog
import org.apache.spark.sql.expressions.SparkUserDefinedFunction
import org.apache.spark.sql.functions._
Expand Down Expand Up @@ -962,6 +963,24 @@ class QueryCompilationErrorsSuite
"methodName" -> "update",
"className" -> "org.apache.spark.sql.catalyst.expressions.UnsafeRow"))
}

test("INTERNAL_ERROR: Convert unsupported data type from Spark to Parquet") {
val converter = new SparkToParquetSchemaConverter
val dummyDataType = new DataType {
override def defaultSize: Int = 0

override def simpleString: String = "Dummy"

override private[spark] def asNullable = NullType
}
checkError(
exception = intercept[AnalysisException] {
converter.convertField(StructField("test", dummyDataType))
Copy link
Member

@MaxGekk MaxGekk Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to reproduce the error using public API? If not, we should think of converting to an internal error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxGekk Replaced it with INTERNAL_ERROR, please check the updated PR description.

},
errorClass = "INTERNAL_ERROR",
parameters = Map("message" -> "Cannot convert Spark data type \"DUMMY\" to any Parquet type.")
)
}
}

class MyCastToString extends SparkUserDefinedFunction(
Expand Down