-
Notifications
You must be signed in to change notification settings - Fork 123
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
alias column for snowflake external table #257
Conversation
@jeremyyeo , the CI seems to be failing, it is not related to this PR |
This is useful. Thanks for the work on this. |
CI fails because of a protobuf issue in DBT Core, I have created a PR with a temporary fix that will resolve this issue: |
@@ -26,12 +26,14 @@ | |||
{%- endfor -%}{%- endif -%} | |||
{%- if not infer_schema -%} | |||
{%- for column in columns %} | |||
{%- set column_alias = column.alias if column.alias else column.name %} | |||
{%- set column_alias_quoted = adapter.quote(column_alias) if column.quote else column_alias %} | |||
{%- set column_quoted = adapter.quote(column.name) if column.quote else column.name %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line needed or used anymore?
{%- set column_quoted = adapter.quote(column.name) if column.quote else column.name %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed as the column_quoted is used in the expression part of the definition, we can't use column_alias_quoted in value: , hope that clarifies the need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cakkinep thanks for opening! Can you add a test case to integration_tests/models/plugins/snowflake/snowflake_external.yml
that takes advantage of this aliasing option?
@dataders Added integration test to validate column alias. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @cakkinep!
Description & motivation
resolves: #213
These changes will specifically solve the issue with snowflake tables where the underlying file format or table format has a column named VALUE ( error below) . In general this change will allow aliasing column name for any reason.
Encountered an error while running operation: Database Error
091311 (42601): SQL compilation error:
'VALUE' cannot be used as a column name for external tables.
More about the changes:
Checklist
I have verified that these changes work locally
I have updated the README.md (if applicable)
I have added an integration test for my fix/feature (if applicable)