I'm running some test cases evaluating dbt using the Synapse provider. I came across this error when adding a new column:
Test Case - Rename Column
Model
{{ config(materialized='incremental'
, index='clustered index(OLDACNUM)'
, dist='REPLICATE'
, on_schema_change='sync_all_columns' ) }}
SELECT TOP (1000)
[RecordCreateRunId]
,[DEBTORNUM]
,[OLDACNUM]
,[CREDCOLACTION]
,[LASTSTMTDATE]
,[CUST_TYPE] AS CustomerType
,[LETTERDATE]
,[CHARGE_CODE]
,[NUM_REMINDERS]
,[PAYMENT_CODE]
,[CYCLE_GROUP]
,ODS_START_DATE
,1 AS NEW_COLUMN
FROM [DBO].[DEBTOR]
{% if is_incremental() %}
-- this filter will only be applied on an incremental run
WHERE ODS_START_DATE > (select max(ODS_START_DATE) from {{ this }})
{% endif %}
Incremental Run
dbt run --select STG_DEBTORS_NEW
Generated Code from Log
Incremental update
...
05:14:39.102035 [debug] [Thread-1 (]: SQLServer adapter: SQL status: OK in 0.04 seconds
05:14:39.120042 [debug] [Thread-1 (]:
In "DBNAME"."DBT"."STG_DEBTORS_NEW":
Schema changed: True
Source columns not in target: [<Column CustomerType (character varying(2))>]
Target columns not in source: [<Column CUST_TYPE (character varying(2))>]
New column types: []
...
alter table "DBNAME"."DBT"."STG_DEBTORS_NEW"
add column CustomerType character varying(2)
,
drop column CUST_TYPE
Outcome
Failed with Error Incorrect syntax near 'column'
Offending code was:
alter table "DBNAME"."DBT"."STG_DEBTORS_NEW"
add column CustomerType character varying(2)
,
drop column CUST_TYPE
should be:
alter table "DBT"."STG_DEBTORS_NEW" add CustomerType varchar(2);
alter table "DBT"."STG_DEBTORS_NEW" drop column CUST_TYPE;
I would suggest a fix, but I couldn't find an SQL server or synapse macro specifically for "rename column" is this just defaulting to the default provider? Happy to submit a PR if someone can point me in the right direction.
Hi.
I'm running some test cases evaluating dbt using the Synapse provider. I came across this error when adding a new column:
Test Case - Rename Column
Model
Incremental Run
Generated Code from Log
Outcome
Failed with Error Incorrect syntax near 'column'
Offending code was:
alter table "DBNAME"."DBT"."STG_DEBTORS_NEW"
should be:
alter table "DBT"."STG_DEBTORS_NEW" add CustomerType varchar(2); alter table "DBT"."STG_DEBTORS_NEW" drop column CUST_TYPE;
I would suggest a fix, but I couldn't find an SQL server or synapse macro specifically for "rename column" is this just defaulting to the default provider? Happy to submit a PR if someone can point me in the right direction.
Versions dbt=1=1=2, sqlserver=1.1.0, synapse=1.1.0