// DuckDB error reference

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
错误信息
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 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();

如何修复它

  1. 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';
  2. 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;
  3. 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%';
  4. 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.

相关错误

代码和消息文本来自 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. 许可详情 引用的错误消息文本归其数据库厂商所有。