dbt-sqlserver icon indicating copy to clipboard operation
dbt-sqlserver copied to clipboard

Bug in incremental model: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near the keyword 'column'. (156) (SQLExecDirectW)")

Open xg1990 opened this issue 3 years ago • 0 comments

The following query failed when the source table has a column removed

{{ config(
    materialized = 'incremental',
    unique_key = 'date',
    on_schema_change = "sync_all_columns",
) }}

SELECT
    DISTINCT *
FROM
    <source table>

The full error message is

('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near the keyword 'column'. (156) (SQLExecDirectW)")

Same error for on_schema_change = "append_new_columns",

and if I use

{{ config(
    materialized = 'incremental',
    unique_key = 'date',
    on_schema_change = "ignore",
) }}

I'll get this error message:

('42S22', "[42S22] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name '<the removed column>'. (207) (SQLExecDirectW)")

xg1990 avatar Apr 21 '22 04:04 xg1990