Binder Error: DuckDB could not plan the query
DuckDB parsed the query but couldn't plan it: a missing column, an alias out of scope, or types that don't fit the function. A missing table raises Catalog Error instead.
- Exception
Binder Error
它的意義
Binder Error means the parser accepted the SQL but the binder could not resolve it against the catalog and the types. This is the class for the most common day-to-day mistakes: a column or table that does not exist, a function called with argument types that have no overload, or a struct key that is not there. DuckDB binds each statement before running it, so a bind error means that statement did not run. Statements earlier in the same script have already run.
The message says exactly which name, column or function signature failed. When the same SQL works elsewhere, compare the schema and the DuckDB version, because different builds ship different function overloads and extensions.
常見原因
- A column name that does not exist in the FROM clause, or a table alias used outside its scope.
- A function called with argument types that match no overload, such as
1 + 'a'或avg(text_column). - A struct or union key that is not present, for example
{'a': 1}.b. - A call to a function from an extension that is not loaded. DuckDB reports that as Catalog Error, not Binder Error.
Find the cause
-- The message names the column, function or key that failed. Check what the connection can actually see: SELECT table_schema, table_name FROM information_schema.tables ORDER BY 1; DESCRIBE my_table; -- Which overloads exist for the function you called: SELECT function_name, parameter_types, return_type FROM duckdb_functions() WHERE function_name = 'substring'; SELECT version();
如何修正
-
Check the names the message mentions against the actual schema before changing the SQL:
DESCRIBE my_table; SELECT table_schema, table_name, column_name FROM information_schema.columns WHERE table_name = 'my_table';
-
Add explicit casts when the binder cannot pick an overload, so the operation is unambiguous:
SELECT int_col + CAST(text_col AS INTEGER) FROM my_table;
-
List the functions that do exist when a name fails. Some names are aliases with the same signatures, such as
group_concat和string_agg:SELECT function_name, parameter_types FROM duckdb_functions() WHERE function_name ILIKE '%agg%';
-
Load the extension a function belongs to when the name is unknown on this connection:
LOAD httpfs;
Other ways to handle it
If the column is genuinely missing, add it with ALTER TABLE rather than editing the query to fit the old schema. If the types are ambiguous, a cast in the query is better than relying on implicit conversion, which DuckDB keeps strict on purpose.
安全地重現問題
SELECT 1 + 'a'; -- 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 or Catalog Error: which one means a missing table?
A table that does not exist gives Catalog Error. A table that exists but lacks the column you named gives Binder Error.
Why does the same query work in another tool?
The other tool may run a different DuckDB version or have extensions loaded. Check version() 和 duckdb_extensions() on both connections.
相關錯誤
Binder ErrorThe column is not in the FROM clauseConversion ErrorThe value cannot be cast to the target typeCatalog ErrorThe table does not exist in this databaseParser ErrorThe SQL does not parseSQLITE_ERRORSQLite: SQL logic error42703PostgreSQL:欄位不存在
程式碼和訊息文字來自 DuckDB documentation。瀏覽完整的 DuckDB error list 或 搜尋每個資料庫錯誤.
Work on DuckDB in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for DuckDB and the other databases you use.
本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情 引用的錯誤訊息文字歸其資料庫廠商所有。