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

bugfix for available dateparts for redshift/snowflake #11

Closed
wants to merge 2 commits into from

Conversation

kzzzr
Copy link

@kzzzr kzzzr commented Feb 18, 2021

A minor fix for iso_* dates.

You see Redshift doesn't support isoweek datepart:
https://docs.aws.amazon.com/redshift/latest/dg/r_Dateparts_for_datetime_functions.html

Neither does Snowflake except for DATE_PART function:
https://docs.snowflake.com/en/sql-reference/functions-date-time.html

Database Error in model dim_calendar (models/marts/dim/dim_calendar.sql)
Invalid datetime part for DATE_TRUNC().
DETAIL:
-----------------------------------------------
error: Invalid datetime part for DATE_TRUNC().
code: 8001
context:
query: 760488
location: datetime_ops.cpp:40
process: padbmaster [pid=6610]
-----------------------------------------------

@clausherther
Copy link
Contributor

Hi @kzzzr, thanks for this PR!
I'm going to have to noodle on this for a bit. The implementation of iso_week_end isn't great, you're right isoweek doesn't work there, but you can see here that the "private" _iso_week_end macro ends not actually using the passed in week_type parameter so I should just remove it.

iso_week_of_year is using date_part so should work on Snowflake as you point out, so I'm ok changing the defaults for Redshift, although then we should really just remove the Redshift version and fail if someone wants to use this on Redshift?

@kzzzr
Copy link
Author

kzzzr commented Feb 23, 2021

Greeting Claus @clausherther,
Sure, the solution is totally up to you. I've seen you used "private" macro deliberately.
This is just a quick fix for my deployment and at the same time opportunity to point to this issue.
Great package, by the way. Thank you, enjoy using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants