SQLSTATE Codes

Most error classes returned by Spark SQL are associated with a 5 character SQLSTATE. A SQLSTATE is a SQL standard encoding for error conditions commonly used by JDBC, ODBC, and other client APIs.

A SQLSTATE consists of two portions: A two character class, and a three character subclass. Each character must be a digit '0' to '9' or 'A' to 'Z'.

While many SQLSTATE values are prescribed by the SQL standard, others are common in the industry, specific to Spark.

For an ordered list of error classes see: Error Conditions in Spark SQL

Spark SQL uses the following SQLSTATE classes:

Class 0A: feature not supported

SQLSTATEDescription and issuing error classes
0A000feature not supported
INVALID_PANDAS_UDF_PLACEMENT, STAR_GROUP_BY_POS, UNSUPPORTED_ARROWTYPE, UNSUPPORTED_DATATYPE, UNSUPPORTED_DESERIALIZER, UNSUPPORTED_FEATURE, UNSUPPORTED_GENERATOR, UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY, UNSUPPORTED_TYPED_LITERAL

Class 21: cardinality violation

SQLSTATEDescription and issuing error classes
21000cardinality violation
SCALAR_SUBQUERY_TOO_MANY_ROWS

Class 22: data exception

SQLSTATEDescription and issuing error classes
22003numeric value out of range
ARITHMETIC_OVERFLOW, CAST_OVERFLOW, CAST_OVERFLOW_IN_TABLE_INSERT, DECIMAL_PRECISION_EXCEEDS_MAX_PRECISION, INVALID_INDEX_OF_ZERO, INCORRECT_END_OFFSET, INCORRECT_RAMP_UP_RATE, INVALID_ARRAY_INDEX, INVALID_ARRAY_INDEX_IN_ELEMENT_AT, NUMERIC_OUT_OF_SUPPORTED_RANGE, NUMERIC_VALUE_OUT_OF_RANGE
22007invalid datetime format
CANNOT_PARSE_TIMESTAMP
22008datetime field overflow
DATETIME_OVERFLOW
2200Enull value in array target
NULL_MAP_KEY
22012division by zero
DIVIDE_BY_ZERO, INTERVAL_DIVIDED_BY_ZERO
22015interval field overflow
INTERVAL_ARITHMETIC_OVERFLOW
22018invalid character value for cast
CANNOT_PARSE_DECIMAL, CAST_INVALID_INPUT, CONVERSION_INVALID_INPUT
22023invalid parameter value
INVALID_FRACTION_OF_SECOND, INVALID_PARAMETER_VALUE, SECOND_FUNCTION_ARGUMENT_NOT_INTEGER
22032invalid JSON text
INVALID_JSON_ROOT_FIELD, INVALID_JSON_SCHEMA_MAP_TYPE
2203Gsql_json_item_cannot_be_cast_to_target_type
CANNOT_PARSE_JSON_FIELD
22546The value for a routine argument is not valid.
CANNOT_DECODE_URL

Class 23: integrity constraint violation

SQLSTATEDescription and issuing error classes
23505A violation of the constraint imposed by a unique index or a unique constraint occurred.
DUPLICATED_MAP_KEY, DUPLICATE_KEY

Class 2B: dependent privilege descriptors still exist

SQLSTATEDescription and issuing error classes
2BP01dependent_objects_still_exist
SCHEMA_NOT_EMPTY

Class 38: external routine exception

SQLSTATEDescription and issuing error classes
38000external routine exception
FAILED_FUNCTION_CALL

Class 39: external routine invocation exception

SQLSTATEDescription and issuing error classes
39000external routine invocation exception
FAILED_EXECUTE_UDF

Class 42: syntax error or access rule violation

SQLSTATEDescription and issuing error classes
42000syntax error or access rule violation
AMBIGUOUS_REFERENCE_TO_FIELDS, INVALID_COLUMN_OR_FIELD_DATA_TYPE, INVALID_EXTRACT_BASE_FIELD_TYPE, INVALID_EXTRACT_FIELD_TYPE, INVALID_FIELD_NAME, INVALID_SET_SYNTAX, INVALID_SQL_SYNTAX, NON_PARTITION_COLUMN, NOT_NULL_CONSTRAINT_VIOLATION, NULLABLE_COLUMN_OR_FIELD, NULLABLE_ROW_ID_ATTRIBUTES
42601A character, token, or clause is invalid or missing.
IDENTIFIER_TOO_MANY_NAME_PARTS, INVALID_EXTRACT_FIELD, INVALID_FORMAT, PARSE_SYNTAX_ERROR, UNCLOSED_BRACKETED_COMMENT
42602A character that is invalid in a name has been detected.
INVALID_IDENTIFIER, INVALID_PROPERTY_KEY, INVALID_PROPERTY_VALUE
42604An invalid numeric or string constant has been detected.
EMPTY_JSON_FIELD_VALUE, INVALID_TYPED_LITERAL
42605The number of arguments specified for a scalar function is invalid.
WRONG_NUM_ARGS
42607An operand of an aggregate function or CONCAT operator is invalid.
NESTED_AGGREGATE_FUNCTION
42613Clauses are mutually exclusive.
INCOMPATIBLE_JOIN_TYPES, INVALID_LATERAL_JOIN_TYPE, NON_LAST_MATCHED_CLAUSE_OMIT_CONDITION, NON_LAST_NOT_MATCHED_BY_SOURCE_CLAUSE_OMIT_CONDITION, NON_LAST_NOT_MATCHED_BY_TARGET_CLAUSE_OMIT_CONDITION
42614A duplicate keyword or clause is invalid.
REPEATED_CLAUSE
42617The statement string is blank or empty.
PARSE_EMPTY_STATEMENT
42702A column reference is ambiguous, because of duplicate names.
AMBIGUOUS_COLUMN_OR_FIELD, AMBIGUOUS_LATERAL_COLUMN_ALIAS
42703An undefined column or parameter name was detected.
COLUMN_NOT_FOUND, UNRESOLVED_COLUMN, UNRESOLVED_FIELD, UNRESOLVED_MAP_KEY, UNRESOLVED_USING_COLUMN_FOR_JOIN
42704An undefined object or constraint name was detected.
AMBIGUOUS_REFERENCE, DEFAULT_DATABASE_NOT_EXISTS, FIELD_NOT_FOUND, INDEX_NOT_FOUND, SCHEMA_NOT_FOUND, UNRECOGNIZED_SQL_TYPE
42710A duplicate object or constraint name was detected.
CREATE_TABLE_COLUMN_OPTION_DUPLICATE, INDEX_ALREADY_EXISTS, LOCATION_ALREADY_EXISTS
42711A duplicate column name was detected in the object definition or ALTER TABLE statement.
COLUMN_ALREADY_EXISTS
42723A routine with the same signature already exists in the schema, module, or compound block where it is defined.
ROUTINE_ALREADY_EXISTS
42803A column reference in the SELECT or HAVING clause is invalid, because it is not a grouping column; or a column reference in the GROUP BY clause is invalid.
GROUPING_COLUMN_MISMATCH, GROUPING_ID_COLUMN_MISMATCH, MISSING_AGGREGATION, MISSING_GROUP_BY, UNRESOLVED_ALL_IN_GROUP_BY
42805An integer in the ORDER BY clause does not identify a column of the result table.
GROUP_BY_POS_OUT_OF_RANGE, ORDER_BY_POS_OUT_OF_RANGE
42809The identified object is not the type of object to which the statement applies.
FORBIDDEN_OPERATION
42818The operands of an operator or function are not compatible or comparable.
INCOMPARABLE_PIVOT_COLUMN
42823Multiple columns are returned from a subquery that only allows one column.
INVALID_SUBQUERY_EXPRESSION
42825The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have compatible columns.
CANNOT_MERGE_INCOMPATIBLE_DATA_TYPE, INCOMPATIBLE_COLUMN_TYPE
42826The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have the same number of columns.
NUM_COLUMNS_MISMATCH
42846Cast from source type to target type is not supported.
CANNOT_CAST_DATATYPE
42883No routine was found with a matching signature.
ROUTINE_NOT_FOUND, UNRESOLVED_ROUTINE
428C4The number of elements on each side of the predicate operator is not the same.
UNPIVOT_VALUE_SIZE_MISMATCH
428EKThe schema qualifier is not valid.
TEMP_VIEW_NAME_TOO_MANY_NAME_PARTS
428FTThe partitioning clause specified on CREATE or ALTER is not valid.
PARTITIONS_ALREADY_EXIST, PARTITIONS_NOT_FOUND
42903Invalid use of an aggregate function or OLAP function.
GROUP_BY_AGGREGATE, GROUP_BY_POS_AGGREGATE, INVALID_WHERE_CONDITION
429BBThe data type of a column, parameter, or SQL variable is not supported.
CANNOT_RECOGNIZE_HIVE_TYPE
42K01data type not fully specified
DATATYPE_MISSING_SIZE, INCOMPLETE_TYPE_DEFINITION
42K02data source not found
DATA_SOURCE_NOT_FOUND
42K03File not found
PATH_NOT_FOUND, RENAME_SRC_PATH_NOT_FOUND
42K04Duplicate file
FAILED_RENAME_PATH, PATH_ALREADY_EXISTS
42K05Name is not valid
INVALID_EMPTY_LOCATION, REQUIRES_SINGLE_PART_NAMESPACE
42K06Invalid type for options
INVALID_OPTIONS
42K07Not a valid schema literal
INVALID_SCHEMA
42K08Not a constant
NON_LITERAL_PIVOT_VALUES
42K09Data type mismatch
DATATYPE_MISMATCH, PIVOT_VALUE_DATA_TYPE_MISMATCH, UNEXPECTED_INPUT_TYPE, UNPIVOT_VALUE_DATA_TYPE_MISMATCH
42K0AInvalid UNPIVOT clause
UNPIVOT_REQUIRES_ATTRIBUTES, UNPIVOT_REQUIRES_VALUE_COLUMNS
42K0BLegacy feature blocked
INCONSISTENT_BEHAVIOR_CROSS_VERSION
42KD9Cannot infer table schema.
UNABLE_TO_INFER_SCHEMA
42P01undefined_table
TABLE_OR_VIEW_NOT_FOUND, VIEW_NOT_FOUND
42P02undefined_parameter
UNBOUND_SQL_PARAMETER
42P06duplicate_schema
SCHEMA_ALREADY_EXISTS
42P07duplicate_table
TABLE_OR_VIEW_ALREADY_EXISTS, TEMP_TABLE_OR_VIEW_ALREADY_EXISTS, VIEW_ALREADY_EXISTS
42P20windowing_error
UNSUPPORTED_EXPR_FOR_WINDOW

Class 46: java ddl 1

SQLSTATEDescription and issuing error classes
46110unsupported feature
CANNOT_MODIFY_CONFIG
46121invalid column name
INVALID_COLUMN_NAME_AS_PATH

Class 53: insufficient resources

SQLSTATEDescription and issuing error classes
53200out_of_memory
UNABLE_TO_ACQUIRE_MEMORY

Class 54: program limit exceeded

SQLSTATEDescription and issuing error classes
54000program limit exceeded
GROUPING_SIZE_LIMIT_EXCEEDED, TOO_MANY_ARRAY_ELEMENTS

Class XX: internal error

SQLSTATEDescription and issuing error classes
XX000internal error
INTERNAL_ERROR

.. include:: /shared/replacements.md