Skip to content

Commit

Permalink
Adjusted comments
Browse files Browse the repository at this point in the history
  • Loading branch information
itholic committed Oct 16, 2024
1 parent eae01b3 commit ab114c9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,12 @@
},
"sqlState" : "22022"
},
"INVALID_CORRUPT_RECORD_TYPE" : {
"message" : [
"The column <columnName> for corrupt records must have the nullable STRING type, but got <actualType>."
],
"sqlState" : "42804"
},
"INVALID_CURSOR" : {
"message" : [
"The cursor is invalid."
Expand Down Expand Up @@ -4852,11 +4858,6 @@
],
"sqlState" : "0A000"
},
"UNSUPPORTED_DATA_TYPE_FOR_CORRUPTED_RECORD" : {
"message" : [
"The field <columnName> for corrupt records must be string type and nullable."
]
},
"UNSUPPORTED_DATA_TYPE_FOR_ENCODER" : {
"message" : [
"Cannot create encoder for <dataType>. Please use a different output data type for your UDF or DataFrame."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object ExprUtils extends QueryErrorsBase {
val f = schema(corruptFieldIndex)
if (!f.dataType.isInstanceOf[StringType] || !f.nullable) {
throw QueryCompilationErrors.invalidFieldTypeForCorruptRecordError(
columnNameOfCorruptRecord)
columnNameOfCorruptRecord, f.dataType)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1327,10 +1327,11 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
messageParameters = Map.empty)
}

def invalidFieldTypeForCorruptRecordError(columnName: String): Throwable = {
def invalidFieldTypeForCorruptRecordError(columnName: String, actualType: DataType): Throwable = {
new AnalysisException(
errorClass = "UNSUPPORTED_DATA_TYPE_FOR_CORRUPTED_RECORD",
messageParameters = Map("columnName" -> toSQLId(columnName)))
errorClass = "INVALID_CORRUPT_RECORD_TYPE",
messageParameters = Map(
"columnName" -> toSQLId(columnName), "actualType" -> toSQLType(actualType)))
}

def dataTypeUnsupportedByClassError(x: DataType, className: String): Throwable = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1510,8 +1510,9 @@ abstract class CSVSuite
.csv(testFile(valueMalformedFile))
.collect()
},
condition = "UNSUPPORTED_DATA_TYPE_FOR_CORRUPTED_RECORD",
parameters = Map("columnName" -> toSQLId(columnNameOfCorruptRecord))
condition = "INVALID_CORRUPT_RECORD_TYPE",
parameters = Map(
"columnName" -> toSQLId(columnNameOfCorruptRecord), "actualType" -> "\"INT\"")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2117,8 +2117,9 @@ abstract class JsonSuite
.schema(schema)
.json(corruptRecords)
},
condition = "UNSUPPORTED_DATA_TYPE_FOR_CORRUPTED_RECORD",
parameters = Map("columnName" -> toSQLId(columnNameOfCorruptRecord))
condition = "INVALID_CORRUPT_RECORD_TYPE",
parameters = Map(
"columnName" -> toSQLId(columnNameOfCorruptRecord), "actualType" -> "\"INT\"")
)

// We use `PERMISSIVE` mode by default if invalid string is given.
Expand All @@ -2134,8 +2135,9 @@ abstract class JsonSuite
.json(path)
.collect()
},
condition = "UNSUPPORTED_DATA_TYPE_FOR_CORRUPTED_RECORD",
parameters = Map("columnName" -> toSQLId(columnNameOfCorruptRecord))
condition = "INVALID_CORRUPT_RECORD_TYPE",
parameters = Map(
"columnName" -> toSQLId(columnNameOfCorruptRecord), "actualType" -> "\"INT\"")
)
}
}
Expand Down

0 comments on commit ab114c9

Please sign in to comment.