-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature] Support contracts in Redshift even when the first row has NULL
values
#10490
Comments
Thanks for reaching out @gekas93 ! This looks like dbt-labs/dbt-redshift#659 where Redshift treats dbt-labs/dbt-redshift#659 (comment) discusses our suggested workaround which is to add something like this to the beginning of your model to handle this Redshift-specific behavior:
Could you try that out and see if it resolves the issue? |
Thanks for your quick response @dbeatty10 ! Sorry, because I tried to find some topics related with mine but I didn't found anything. Yes, with your approach it's working but it's a problem when you have a big number of columns. In my case, in this table I have like 50 columns, so I had to add more than 50 code lines and 50 manual casts. There will be some approach in the future that will solve this? Obviously, if I add the IFNULL operation in a previously model and it's materialized as a table, I don't have this issue. But if it's materialized as a view (in my case has to be like that), it is still there. |
NULL
values
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. |
still open |
Is this a new bug in dbt-core?
Current Behavior
I'm having a strange issue with the contracts in my dbt model and working with redshift.
I have fixed some fields with a data_type = 'date' and they were working well but I have added a NULLIF condition like this:
Before of adding the NULLIF function, everything works as expected.
After adding it I am having this message:
I have tried to cast in each place (before, after, in the middle more than one time) but I always have the same issue. I tried to use a case instead of NULLIF but the same happens.
I have token a look in the macros and I have see that it's this macro the responsible of the behaviour:
I have added two logs at the end to confirm it. The sql_file_provided_columns is giving me the dates as a varchar.
Expected Behavior
DBT detects that the definition type is DATE for plant_start_date and plant_end_date
Steps To Reproduce
cast(NULLIF(<date_field>, '9999-12-31') as date) as <date_field_name>
Relevant log output
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response
The text was updated successfully, but these errors were encountered: