// 错误参考

DuckDB error codes

DuckDB does not use numeric error codes. Every failure is an exception class such as Binder Error 或者 Conversion Error, printed at the start of the message, with the details after the colon. The ones you are likely to meet have a full page with causes and fixes.

Reading a DuckDB error

DuckDB raises exception classes instead of codes. The class name is the prefix of the message, for example Binder Error: Column "x" not found. Match on the prefix for the broad kind of problem and on the message text for the exact one.

Drivers surface the classes differently: Python raises duckdb.BinderException, duckdb.ConversionException and friends, while ADO.NET and JDBC wrap everything in their own exception types and carry the DuckDB message as text. Check ExceptionType or the message prefix, never a code.

Two classes mean very different things despite similar names: Conversion Error is a value that cannot be cast, and Out of Range Error is arithmetic overflow inside an operation.

A Catalog Error almost always means you are connected to a different database than you think, so check what tables actually exist before rewriting the query.

All DuckDB errors in this reference

28 codes, 16 with a full write-up (linked). Codes and messages are from the DuckDB documentation.

Binder Error

代码含义
Binder Error DuckDB could not plan the query Binder Error: Could not choose a best candidate function for the function call "+(INTEGER_LITERAL, STRING_LITERAL)". In order to select one, please add explicit type casts.
Binder Error The column is not in the FROM clause Binder Error: Referenced column "nope" not found in FROM clause!

Catalog Error

代码含义
Catalog Error The table does not exist in this database Catalog Error: Table with name no_such_table does not exist!
Catalog Error The table or object already exists Catalog Error: Table with name "t" already exists!
Catalog Error The schema does not exist in this database Catalog Error: Schema with name no_such_schema does not exist!
Catalog Error The column name is already taken Catalog Error: Column with name "a" already exists!

Conversion and range errors

代码含义
Conversion Error The value cannot be cast to the target type Conversion Error: Could not convert string 'abc' to INT32
Conversion Error The value is out of range for INT32 Conversion Error: Type INT64 with value 99999999999 can't be cast because the value is out of range for the destination type INT32
Conversion Error The date or timestamp string is malformed Conversion Error: invalid date field format: "not a date", expected format is (YYYY-MM-DD)
Out of Range Error Arithmetic overflow Out of Range Error: Overflow in multiplication of INT8 (100 * 100)!

Type errors

代码含义
Invalid type Error A type was used where it is not supported Invalid type Error: Unimplemented type for cast (TIME WITH TIME ZONE)

Constraint Error

代码含义
Constraint Error A NOT NULL column received NULL Constraint Error: NOT NULL constraint failed: t.a
Constraint Error A duplicate key violates a unique constraint Constraint Error: Duplicate key "a: 1" violates primary key constraint.
Constraint Error A CHECK constraint rejected the row Constraint Error: CHECK constraint failed on table "t" with expression CHECK((a > 0))

IO and permission errors

代码含义
IO Error A file could not be opened IO Error: Cannot open file "/tmp/missing/db.duckdb": No such file or directory
IO Error Permission to the file was denied IO Error: Cannot open file "/data/db.duckdb": Permission denied
IO Error The database file is locked by another process IO Error: Could not set lock on file "/data/db.duckdb": Conflicting lock is held by another process. See also https://duckdb.org/docs/current/connect/concurrency
Permission Error DuckDB policy refused the operation Permission Error: Cannot access file "/tmp/xx.csv" - file system operations are disabled by configuration

Memory and resource errors

代码含义
Out of Memory Error The query hit DuckDB's memory limit Out of Memory Error: failed to allocate data of size 32.0 MiB (48.1 MiB/61.0 MiB used)
Interrupted Error The query was cancelled Interrupted Error: Interrupted!

Parser and syntax errors

代码含义
Parser Error The SQL does not parse Parser Error: syntax error at or near "SELEC"

Transaction errors

代码含义
TransactionContext Error The transaction hit a conflict TransactionContext Error: Conflict on update!

Extension and feature errors

代码含义
Not implemented Error A feature DuckDB lacks was requested Not implemented Error: ORDER BY within aggregates with DISTINCT is not implemented
Serialization Error The database file version is incompatible Serialization Error: Loading a database file written by a different DuckDB version is not supported

Function errors

代码含义
Catalog Error The function does not exist Catalog Error: Scalar Function with name no_such_fn does not exist!
Invalid Input Error An invalid regular expression Invalid Input Error: missing ]: [
Invalid Input Error Malformed JSON input Invalid Input Error: Malformed JSON at byte 1 of input: unexpected character. Input: "{bad"
Binder Error No overload matches the argument types Binder Error: No function matches the given name and argument types 'substring(STRING_LITERAL)'. You might need to add explicit type casts.
// 一个客户端,覆盖所有引擎

A faster way to work with DuckDB

SQLly 是 macOS、Windows 和 Linux 的原生 SQL 客户端,具备模式感知的 IntelliSense,并为高风险语句提供护栏。

本页文字和数据: CC BY 4.0,请注明出处 SQLly (sqlly.app)。 代码和 SQL 片段: MIT. 许可详情 引用的错误消息文本归其数据库厂商所有。