// 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. ライセンスの詳細 引用したエラーメッセージの文言は、各データベースベンダーに帰属します。