-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
[Don't Merge] Issue 258 - Update to rank and fix operator #260
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ | |||||||||||||||
value_set, | ||||||||||||||||
top_n, | ||||||||||||||||
quote_values=True, | ||||||||||||||||
data_type="decimal", | ||||||||||||||||
data_type=None, | ||||||||||||||||
row_condition=None | ||||||||||||||||
) -%} | ||||||||||||||||
|
||||||||||||||||
|
@@ -22,6 +22,8 @@ | |||||||||||||||
row_condition | ||||||||||||||||
) %} | ||||||||||||||||
|
||||||||||||||||
{% set data_type = dbt.type_numeric() if not data_type else data_type %} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi, Snowflake won't correctly compare a float in the db to a value cast to decimal (default for the test) so makes more sense to use the built-in types across the test to make sure comparisons actually work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the official documentation and my testing, inserting floating point data will create a When comparing, Snowflake will happily attempt to compare any numeric type with the usual issues from floats
TL;DR: It makes sense to use built-in types everywhere to not get db-engine specific issues. |
||||||||||||||||
|
||||||||||||||||
with value_counts as ( | ||||||||||||||||
|
||||||||||||||||
select | ||||||||||||||||
|
@@ -48,7 +50,7 @@ value_counts_ranked as ( | |||||||||||||||
|
||||||||||||||||
select | ||||||||||||||||
*, | ||||||||||||||||
row_number() over(order by value_count desc) as value_count_rank | ||||||||||||||||
rank() over(order by value_count desc) as value_count_rank | ||||||||||||||||
from | ||||||||||||||||
value_counts | ||||||||||||||||
|
||||||||||||||||
|
@@ -60,7 +62,7 @@ value_count_top_n as ( | |||||||||||||||
from | ||||||||||||||||
value_counts_ranked | ||||||||||||||||
where | ||||||||||||||||
value_count_rank = {{ top_n }} | ||||||||||||||||
value_count_rank <= {{ top_n }} | ||||||||||||||||
|
||||||||||||||||
), | ||||||||||||||||
set_values as ( | ||||||||||||||||
|
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 there any database engine that wouldn't automatically cast every subsequent value on insert when the first value has an explicit type? (it doesn't hurt to cast them all, I'm curious and couldn't find the information online)