-
Notifications
You must be signed in to change notification settings - Fork 59
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
[CT-2161] [Feature] Support altering tables dist/sort keys #333
Comments
Thanks for reporting this @alejandrofm ! Could you share a simple example of a model (and its configuration) that could run into this problem? Specifically, it would be nice to see which materialization type you are using (table, incremental, etc) and also which config parameters you are using. e.g., could you share something like this? -- Example with interleaved sort keys
{{ config(materialized='table',
sort_type='interleaved'
sort=['id', 'category'],
dist='received_at')
}}
select ... |
Sure! this is the config: {{
config(
materialized='incremental',
sql_where="TRUE",
unique_key="events_date",
incremental_strategy='delete+insert',
sort=['column1', 'column2', 'column3'],
dist='column1'
)
}} |
Thanks for providing this config @alejandrofm I haven't tried it myself yet. Do you think it would be solved if #335 is implemented? (Thanks for opening both of these issues, by the way! Good stuff.) |
Will solve it only if the ALTER COLUMN is done for increasing as well as decreasing field sizes. Increasing is "easy", decreasing needs one check to know if the old data fits on the new field size. |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
I'm just bumping it so it doesn't get closed, it's a real issue for several use cases. Thanks |
Any updates on fixing this behavior? It seems intermittent in my production environment. |
I think we should treat this as a new feature and fully support altering tables dist/sort keys in addition to columns similar to what we do now for materialized views. |
@colin-rogers-dbt This might be the same/similar to #335. Do you think this could be the key part of the implementation (in addition to applicable test cases)? {% macro redshift__alter_column_type(relation, column_name, new_column_type) -%}
{% call statement('alter_column_type') %}
alter table {{ relation }} alter column {{ adapter.quote(column_name) }} type {{ new_column_type }};
{% endcall %}
{% endmacro %} |
Per @rriley99 here,
|
Is this a new bug in dbt-redshift?
Current Behavior
Edited the size of a varchar field on Redshift, DBT makes an update to recreate the column, after the update it tries to drop de column but can't because is a SORTKEY.
Expected Behavior
The SORTKEY must be changed (or dropped) before trying to update the field, and then it have to be recreated
Steps To Reproduce
Change the length of a varchar field (must be sortkey) on the destination table on Redshift.
Run the dbt model
Relevant log output
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: