microsoft/dbt-synapse

alter column type syntax error on incremental models

dlarsen5 opened this issue · 1 comments

running an incremental model calls the macro alter_column_type which has the incorrect syntax (possibly brought over from sql server?) of alter table <table_name> add column <column_name> <type> when it should be alter table <table_name> add <column_name> <type>

Here is the log output (model/column names changed)

2021-09-23 16:00:50.330909 (Thread-3): Changing col type from character varying(20) to character varying(255) in table <table_name>
2021-09-23 16:00:50.343175 (Thread-3): Using synapse connection <model_name>.
2021-09-23 16:00:50.344859 (Thread-3): On <model_name>: 
    alter table <table_name> add column <alter_column> character varying(255);
    update <table_name> set <alter_column> = <column_name>;
    alter table <table_name> drop column <column_name> cascade;
    alter table <table_name> rename column <alter_column> to <column_name>
  
2021-09-23 16:01:01.595936 (Thread-3): Database error: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Parse e
rror at line: 2, column: 66: Incorrect syntax near 'column'. (103010) (SQLExecDirectW)")
2021-09-23 16:01:01.599486 (Thread-3): On <model_name>: ROLLBACK
2021-09-23 16:01:01.602760 (Thread-3): On <model_name>: Close
2021-09-23 16:01:01.605614 (Thread-3): Error running SQL: macro alter_column_type

Possible related to #59