Share via


SQLSTATE error codes

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 12.2 and above

All error classes returned by Azure Databricks 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, or Azure Databricks.

Where necessary Spark and Azure Databricks use the 'KD' class and 'K**' subclass ranges for custom SQLSTATEs. The class 'XX' is used for internal errors warranting a bug report.

For an ordered list of error classes see: Error handling in Azure Databricks

Azure Databricks uses the following SQLSTATE classes:

Class 07: dynamic SQL error

SQLSTATE Description and issuing error conditions
07001 using clause does not match dynamic parameter specifications
07501 The option specified on PREPARE or EXECUTE is not valid.

Class 08: connection exception

SQLSTATE Description and issuing error conditions
08000 connection exception
08001 SQL-client unable to establish SQL-connection
08003 connection does not exist
08006 connection failure
08KD1 server busy

Class 0A: feature not supported

SQLSTATE Description and issuing error conditions
0A000 feature not supported
0AKD0 Cross catalog or schema operation not supported
0AKD1 Security feature not supported
0AKDC Not supported in Delta
0AKDD Feature requires Delta
0AKDE Feature non enabled for this Delta table
0AKLT Feature non enabled in Delta Live
0AKUC Not supported in Unity Catalog
0AKUD Feature requires Unity Catalog

Class 0B: invalid transaction initiation

SQLSTATE Description and issuing error conditions
0B000 invalid transaction initiation

Class 0K: resignal when handler not active

SQLSTATE Description and issuing error conditions
0K000 resignal when handler not active

Class 0N: SQL/XML mapping error

SQLSTATE Description and issuing error conditions
0N000 SQL/XML mapping error

Class 21: cardinality violation

SQLSTATE Description and issuing error conditions
21000 cardinality violation
21506 The same row of a table cannot be the target for more than one of an update, delete or insert operation.
21S01 Insert value list does not match column list

Class 22: data exception

SQLSTATE Description and issuing error conditions
22000 data exception
22001 string data, right truncation
22003 numeric value out of range
22004 null value not allowed
22005 error in assignment
22006 invalid interval format
22007 invalid datetime format
22008 datetime field overflow
22009 invalid time zone displacement value
2200E null value in array target
2200G most specific type mismatch
2200P interval value out of range
22012 division by zero
22015 interval field overflow
22018 invalid character value for cast
2201B invalid regular expression
2201E invalid argument for natural logarithm
22022 indicator overflow
22023 invalid parameter value
22024 unterminated C string
22029 noncharacter in UCS string
22032 invalid JSON text
2203G sql json item cannot be cast to target type
22525 Partitioning key value is not valid.
22531 The argument of a built-in or system provided routine resulted in an error.
22546 The value for a routine argument is not valid.
22KD0 Transient error
22KD1 Invalid URI or PATH
22KD2 Identity claim is unset
22KD3 Cannot evolve source type to target type.
22P02 invalid text representation
22P03 invalid binary representation

Class 23: integrity constraint violation

SQLSTATE Description and issuing error conditions
23001 restrict violation
23502 An insert or update value is null, but the column cannot contain null values.
23505 A violation of the constraint imposed by a unique index or a unique constraint occurred.
23512 The check constraint cannot be added, because the table contains rows that do not satisfy the constraint definition.
23K01 MERGE cardinality violation

Class 25: invalid transaction state

SQLSTATE Description and issuing error conditions
25000 invalid transaction state

Class 28: invalid authorization specification

SQLSTATE Description and issuing error conditions
28000 invalid authorization specification

Class 2B: dependent privilege descriptors still exist

SQLSTATE Description and issuing error conditions
2BP01 dependent objects still exist

Class 2D: invalid transaction termination

SQLSTATE Description and issuing error conditions
2D521 SQL COMMIT or ROLLBACK are invalid in the current operating environment.
2DKD0 Post commit hook failed.

Class 35: invalid condition number

SQLSTATE Description and issuing error conditions
35000 invalid condition number

Class 38: external routine exception

SQLSTATE Description and issuing error conditions
38000 external routine exception

Class 39: external routine invocation exception

SQLSTATE Description and issuing error conditions
39000 external routine invocation exception

Class 3D: invalid catalog name

SQLSTATE Description and issuing error conditions
3D000 invalid catalog name

Class 3F: invalid schema name

SQLSTATE Description and issuing error conditions
3F000 invalid schema name

Class 40: transaction rollback

SQLSTATE Description and issuing error conditions
40000 transaction rollback

Class 42: syntax error or access rule violation

SQLSTATE Description and issuing error conditions
42000 syntax error or access rule violation
42001 Invalid encoder error
42501 The authorization ID does not have the privilege to perform the specified operation on the identified object.
42601 A character, token, or clause is invalid or missing.
42602 A character that is invalid in a name has been detected.
42604 An invalid numeric or string constant has been detected.
42605 The number of arguments specified for a scalar function is invalid.
42607 An operand of an aggregate function or CONCAT operator is invalid.
42608 The use of NULL or DEFAULT in VALUES or an assignment statement is invalid.
42611 The column, argument, parameter, or global variable definition is invalid.
42612 The statement string is an SQL statement that is not acceptable in the context in which it is presented.
42613 Clauses are mutually exclusive.
42614 A duplicate keyword or clause is invalid.
42616 Invalid options specified
42617 The statement string is blank or empty.
42621 The check constraint or generated column expression is invalid.
42623 A DEFAULT clause cannot be specified.
42701 The same target is specified more than once for assignment in the same SQL statement.
42702 A column reference is ambiguous, because of duplicate names.
42703 An undefined column or parameter name was detected.
42704 An undefined object or constraint name was detected.
42710 A duplicate object or constraint name was detected.
42711 A duplicate column name was detected in the object definition or ALTER TABLE statement.
42713 A duplicate object was detected in a list or is the same as an existing object.
42723 A routine with the same signature already exists in the schema, module, or compound block where it is defined.
42734 A duplicate parameter-name, SQL variable name, label, or condition-name was detected.
4274K Invalid use of a named argument when invoking a routine.
42802 The number of target values is not the same as the number of source values.
42803 A 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.
42804 The result expressions in a CASE expression are not compatible.
42805 An integer in the ORDER BY clause does not identify a column of the result table.
42806 A value cannot be assigned to a variable, because the data types are not compatible.
42807 The data-change statement is not permitted on this object.
42808 A column identified in the INSERT or UPDATE operation is not updatable.
42809 The identified object is not the type of object to which the statement applies.
42815 The data type, length, scale, value, or CCSID is invalid.
42816 A datetime value or duration in an expression is invalid.
42818 The operands of an operator or function are not compatible or comparable.
42822 An expression in the ORDER BY clause or GROUP BY clause is not valid.
42823 Multiple columns are returned from a subquery that only allows one column.
42825 The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have compatible columns.
42826 The rows of UNION, INTERSECT, EXCEPT, or VALUES do not have the same number of columns.
42830 The foreign key does not conform to the description of the parent key.
42832 The operation is not allowed on system objects.
42836 The specification of a recursive, named derived table is invalid.
42837 The column cannot be altered, because its attributes are not compatible with the current column attributes.
42845 An invalid use of a NOT DETERMINISTIC or EXTERNAL ACTION function was detected.
42846 Cast from source type to target type is not supported.
42852 The privileges specified in GRANT or REVOKE are invalid or inconsistent. (For example, GRANT ALTER on a view.)
42883 No routine was found with a matching signature.
42887 The function or table-reference is not valid in the context where it occurs.
42891 A duplicate constraint already exists.
42893 The object or constraint cannot be dropped, altered, or transferred or authorities cannot be revoked from the object, because other objects are dependent on it.
428B3 An invalid SQLSTATE was specified.
428C4 The number of elements on each side of the predicate operator is not the same.
428EK The schema qualifier is not valid.
428FR A column cannot be altered as specified.
428FT The partitioning clause specified on CREATE or ALTER is not valid.
428GU A table must include at least one column that is not implicitly hidden.
428H2 Data type is not supported in the context where it is being used.
428HD The statement cannot be processed because a column mask cannot be applied or the definition of the mask conflicts with the statement.
42902 The object of the INSERT, UPDATE, or DELETE is also identified (possibly implicitly through a view) in a FROM clause.
42903 Invalid use of an aggregate function or OLAP function.
42908 The statement does not include a required column list.
42939 The name cannot be used, because the specified identifier is reserved for system use.
42996 A specified column may not be used in a partition key.
429BB The data type of a column, parameter, or SQL variable is not supported.
429BQ The specified alter of the data type or attribute is not allowed.
42K01 data type not fully specified
42K02 data source not found
42K03 File not found
42K04 Duplicate file
42K05 Name is not valid
42K06 Invalid type for options
42K07 Not a valid schema literal
42K08 Not a constant
42K09 Data type mismatch
42K0A Invalid UNPIVOT clause
42K0B Legacy feature blocked
42K0C Ambiguous reference to constraint
42K0D Invalid lambda function
42K0E An expression is not valid in the context it is used
42K0F A persisted object cannot reference a temporary object.
42K0G A protobuf is invalid
42K0H A cyclic invocation has been detected.
42K0I SQL Config not found.
42K0K Invalid inverse distribution function
42K0L Invalid usage of labels.
42K0M Invalid variable declaration.
42K0N Invalid external type.
42K0O ScalarFunction not overrides method 'produceResult(InternalRow)' with custom implementation.
42K0P ScalarFunction not implements or overrides method 'produceResult(InternalRow)'.
42K0Q Invalid handler declaration.
42K0R Invalid condition declaration.
42K10 Invalid Dynamic Option
42KD0 Ambiguous name reference.
42KD1 Operation not supported in READ ONLY session mode.
42KD2 The source and target table names of a SYNC operaton must be the same.
42KD3 A column can not be added as specified.
42KD4 Operation not supported because table schema has changed.
42KD5 Cannot create file or path.
42KD6 No partition information found.
42KD7 Table signature mismatch.
42KD8 Column position out of range.
42KD9 Cannot infer table schema.
42KDA Failed to merge file into table schema.
42KDB Invalid URL
42KDC Archived file reference.
42KDD Unsupported operation in streaming view.
42KDE Unsupported operation on streaming dataset.
42KDF A required routine parameter is missing an argument.
42KDG The target schema is not compatible with the ingested data.
42KDH Invalid source for filtering service.
42P01 undefined table
42P02 undefined parameter
42P06 duplicate schema
42P07 duplicate table
42P08 ambiguous parameter
42P10 invalid column reference
42P18 indeterminate datatype
42P20 windowing error
42P21 collation mismatch
42P22 indeterminate collation
42S22 Column not found
42S23 Partition transform expression not in 'partitionedBy'

Class 44: with check option violation

SQLSTATE Description and issuing error conditions
44000 with check option violation

Class 46: Java DDL 1

SQLSTATE Description and issuing error conditions
46103 unresolved class name
46110 unsupported feature
46121 invalid column name

Class 51: Invalid Application State

SQLSTATE Description and issuing error conditions
51000 Invalid Application State
51024 An object cannot be used, because it has been marked inoperative.

Class 53: insufficient resources

SQLSTATE Description and issuing error conditions
53000 insufficient resources
53100 disk full
53200 out of memory

Class 54: program limit exceeded

SQLSTATE Description and issuing error conditions
54000 program limit exceeded
54001 The statement is too long or too complex.
54006 The result string is too long.
54023 too many arguments
54K00 Maximum depth of nested views was exceeded.
54KD0 Maximum UDF count in query plan exceeded.
54KD1 Maximum object count in session exceeded.

Class 55: object not in prerequisite state

SQLSTATE Description and issuing error conditions
55000 object not in prerequisite state
55019 The object is in an invalid state for the operation.

Class 56: Miscellaneous SQL or Product Error

SQLSTATE Description and issuing error conditions
56000 Miscellaneous SQL or Product Error
56038 The requested feature is not supported in this environment.
56098 An error occurred during implicit rebind, recompile, or revalidation.
56K00 Spark Connect error

Class 57: operator intervention

SQLSTATE Description and issuing error conditions
57000 operator intervention
57012 A non-database resource is not available. This will not affect the successful execution of subsequent statements.
57KD0 Query execution timeout

Class 58: System error

SQLSTATE Description and issuing error conditions
58000 System error
58030 I/O error

Class 82: out of memory

SQLSTATE Description and issuing error conditions
82100 out of memory (could not allocate)

Class F0: configuration file error

SQLSTATE Description and issuing error conditions
F0000 configuration file error

Class HV: FDW-specific condition

SQLSTATE Description and issuing error conditions
HV000 FDW-specific condition
HV091 invalid descriptor field identifier

Class HY: CLI-specific condition

SQLSTATE Description and issuing error conditions
HY000 CLI-specific condition
HY008 operation canceled
HY109 invalid cursor position

Class KD: datasource specific errors

SQLSTATE Description and issuing error conditions
KD000 datasource specific errors
KD001 Cannot read file footer
KD002 Unexpected version
KD003 Incorrect access to data type
KD004 Delta protocol version error
KD005 Table must include at least one non partition column
KD006 No commits found at log path
KD007 Table signature changed
KD008 Table signature not set
KD009 Partitions do not match
KD00A Unexpected partial scan
KD00B Unrecognised file
KD00C Versioning not contiguous
KD00D Stats required
KD00E table feature validation failure
KD00F cloud request error
KD010 external data source failure
KDL01 cluster launch error

Class P0: procedural logic error

SQLSTATE Description and issuing error conditions
P0001 raise exception