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
9 changes: 9 additions & 0 deletions core/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@
"message" : [ "The target JDBC server does not support transaction and can only support ALTER TABLE with a single action." ],
"sqlState" : "0A000"
},
"UP_CAST_AS_ATTRIBUTE_UNSUPPORTED" : {
"message" : [ "Cannot up cast %s from %s to %s as it may truncate" ]
},
"UP_CAST_FAILURE" : {
"message" : [ "Cannot up cast %s from %s to %s.\nThe type path of the target object is:\n%sYou can either add an explicit cast to the input data or choose a higher precision type of the field in the target object" ]
},
"UP_CAST_UNSUPPORTED_ABSTRACT_DATA_TYPE" : {
"message" : [ "UpCast only support DecimalType as AbstractDataType yet, but got: %s" ]
},
"WRITING_JOB_ABORTED" : {
"message" : [ "Writing job aborted" ],
"sqlState" : "40000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,21 @@ object QueryCompilationErrors {
def upCastFailureError(
fromStr: String, from: Expression, to: DataType, walkedTypePath: Seq[String]): Throwable = {
new AnalysisException(
s"Cannot up cast $fromStr from " +
s"${from.dataType.catalogString} to ${to.catalogString}.\n" +
s"The type path of the target object is:\n" + walkedTypePath.mkString("", "\n", "\n") +
"You can either add an explicit cast to the input data or choose a higher precision " +
"type of the field in the target object")
errorClass = "UP_CAST_FAILURE",
messageParameters = Array(
fromStr,
from.dataType.catalogString,
to.catalogString,
walkedTypePath.mkString("", "\n", "\n")
)
)
}

def unsupportedAbstractDataTypeForUpCastError(gotType: AbstractDataType): Throwable = {
new AnalysisException(
s"UpCast only support DecimalType as AbstractDataType yet, but got: $gotType")
errorClass = "UP_CAST_UNSUPPORTED_ABSTRACT_DATA_TYPE",
messageParameters = Array(gotType.toString)
)
}

def outerScopeFailureForNewInstanceError(className: String): Throwable = {
Expand Down Expand Up @@ -417,9 +422,13 @@ object QueryCompilationErrors {

def cannotUpCastAsAttributeError(
fromAttr: Attribute, toAttr: Attribute): Throwable = {
new AnalysisException(s"Cannot up cast ${fromAttr.sql} from " +
s"${fromAttr.dataType.catalogString} to ${toAttr.dataType.catalogString} " +
"as it may truncate")
new AnalysisException(
errorClass = "UP_CAST_AS_ATTRIBUTE_UNSUPPORTED",
messageParameters = Array(
fromAttr.sql,
fromAttr.dataType.catalogString,
toAttr.dataType.catalogString)
)
}

def functionUndefinedError(name: FunctionIdentifier): Throwable = {
Expand Down