Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADAP-885] [Bug] Dynamic table alter syntax and comment syntax is wrong #769

Closed
2 tasks done
kaarthik108 opened this issue Sep 13, 2023 · 9 comments · Fixed by #770, kaarthik108/dbt-snowflake#1 or #790
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@kaarthik108
Copy link
Contributor

Is this a new bug in dbt-snowflake?

  • I believe this is a new bug in dbt-snowflake
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

DBT tries to comment on the model with a wrong syntax statement

comment on dynamic_table model_name AS

Instead of

comment on dynamic table model_name AS

Also, during the alter process

it tries to do

alter dynamic_table sandbox.procs.customer alter

instead of

alter dynamic table sandbox.procs.customer alter

Expected Behavior

comment on dynamic table model_name AS

and

alter dynamic table sandbox.procs.customer alter

Steps To Reproduce

To be able to change the 'dynamic_table' keyword to 'dynamic table'

Relevant log output

No response

Environment

- OS:Mac os
- Python: 3.8.16
- dbt-core: 1.6.2
- dbt-snowflake: 1.6.2

Additional Context

No response

@kaarthik108 kaarthik108 added bug Something isn't working triage labels Sep 13, 2023
@github-actions github-actions bot changed the title [Bug] Dynamic table alter syntax and comment syntax is wrong [ADAP-885] [Bug] Dynamic table alter syntax and comment syntax is wrong Sep 13, 2023
@mikealfare
Copy link
Contributor

mikealfare commented Sep 14, 2023

@kaarthik108, when you say "during the alter process", are you referring to altering comments?

Nevermind, I found what you're talking about. You already have a PR open for the first fix, would you be willing to finish this off by updating the second macro as well?

@kaarthik108
Copy link
Contributor Author

kaarthik108 commented Sep 14, 2023

@mikealfare
Yes I have fixed it now

@Gyllsdorff
Copy link

Gyllsdorff commented Sep 16, 2023

alter dynamic table sandbox.procs.customer alter

Is that the correct syntax for a dynamic table? alter table sandbox.procs.customer alter works fine for a dynamic table.

https://docs.snowflake.com/en/sql-reference/sql/alter-table-column
vs
https://docs.snowflake.com/en/sql-reference/sql/alter-dynamic-table

It looks like ALTER DYNAMIC TABLE is only used to change the dynamic table properties, the columns is treated as a regular table and should be changed using either ALTER TABLE x ALTER COLUMN y COMMENT $$z$$; or COMMENT ON.

SHOW DYNAMIC TABLES LIKE 'x';
> [1 line]

alter dynamic table dev.test_schema.x alter "column_1" COMMENT $$test comment$$;
> Syntax error: unexpected 'alter'. (line 1)

alter table dev.test_schema.x alter "column_1" COMMENT $$test comment$$;
> Statement executed successfully.

@mikealfare
Copy link
Contributor

Nice catch @Gyllsdorff. I'm surprised that's the syntax, but it looks like you're correct. If you want to submit a PR I can review it. Otherwise I'll take a look next week.

@mikealfare mikealfare reopened this Sep 16, 2023
@kaarthik108
Copy link
Contributor Author

Alright, thanks for pointing that @Gyllsdorff .
A weird syntax

@patkearns10
Copy link
Contributor

@mikealfare I might have done the fork / PR wrong, but the above change should do it.
kaarthik108@edbf910

@dearhari
Copy link

dearhari commented Oct 1, 2023

Hi @kaarthik108
I upgraded to Snowflake adapter 1.6.4 and tested it with a dynamic table. My model yml has column descriptions and when run a dbt build, I get an error and this to do with the alter statement..

In Snowflake the syntax that works for dynamic table is as shown below:

alter table dim_airport alter airport_code comment 'Airport code (IATA 3 letter code)',
airport_description comment 'Airport Description',
city comment 'City';

You don't need the word "dynamic" in the alter statement.

Can you confirm if your fix covers the above?

@kaarthik108
Copy link
Contributor Author

Hi @dearhari , yes that's the fix I have corrected in the latest PR.
for the alter table comment.

It doesn't work on 1.6.4, currently it is alter dynamic table table_name alter
This is now fixed on #790

@dearhari
Copy link

dearhari commented Oct 2, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
6 participants