-
Notifications
You must be signed in to change notification settings - Fork 1
bugfix/cast_strings_as_floats #33
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
Changes from 5 commits
0a87567
d1fa7d3
23a1548
d90ca94
427e7ad
582578f
19f9470
f254ec0
e12e7b8
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 |
|---|---|---|
|
|
@@ -44,9 +44,24 @@ final as ( | |
| active_status_date, | ||
| annual_currency_summary_currency, | ||
| annual_currency_summary_frequency, | ||
| annual_currency_summary_primary_compensation_basis, | ||
| annual_currency_summary_total_base_pay, | ||
| annual_currency_summary_total_salary_and_allowances, | ||
| {% set string_dtypes = ['char', 'text', 'string'] %} | ||
|
Contributor
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. I don't think 'text' is a string data type in Databricks. It's harmless if it's there, but might be worth double-checking if it's safe to remove.
Contributor
Author
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. Removed. |
||
| {% for col in adapter.get_columns_in_relation(ref('stg_workday__worker_base')) %} | ||
| {% if col.name.lower() in ['annual_currency_summary_primary_compensation_basis', 'annual_currency_summary_total_base_pay', 'annual_currency_summary_total_salary_and_allowances'] %} | ||
| {% if target.type == 'databricks' %} | ||
|
Contributor
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. I think there is a silent failure when running against databricks here. Variables set inside a I tested with this configuration in And when running You end up seeing that these fields are not cast to floats and remain as strings.
So the Databricks case isn't quite solved as of yet. I wonder if we can use the Jinja namespace capability, to do the data type check, and then change the value to
Contributor
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. Looks like the latest changes fixed this!
Contributor
Author
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. namespace was the key. |
||
| {% set is_str = false %} | ||
| {% for stype in string_dtypes %} | ||
| {% if stype in col.dtype.lower() %}{% set is_str = true %}{% endif %} | ||
| {% endfor %} | ||
| {% else %} | ||
| {% set is_str = col.is_string() %} | ||
| {% endif %} | ||
| {% if is_str %} | ||
| cast({{ col.name }} as {{ dbt.type_float() }}) as {{ col.name }}, | ||
| {% else %} | ||
| {{ col.name }}, | ||
| {% endif %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| annual_summary_currency, | ||
| annual_summary_frequency, | ||
| annual_summary_primary_compensation_basis, | ||
|
|
||

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.
These fields are also present in the base
stg_workday__workermodel. Should we apply the macro there as well?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.
per this comment in the Jira ticket, the decision was to only apply to the worker_history table.