-
Notifications
You must be signed in to change notification settings - Fork 31
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
convert cent based fields to major currency unit based #87
Conversation
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.
@fivetran-reneeli thanks for applying these updates. I have a few comments below before approval. Let me know if you would like to discuss in more detail.
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.
@fivetran-reneeli thanks for these edits, a few more comments in the review. Thanks!
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.
A few remaining comments before approval. Let me know if you have any questions.
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
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.
Thanks @fivetran-joemarkiewicz , changes applied!
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.
@fivetran-reneeli a few more change suggestions and notes before approval. The largest change is the request to make the macro more dynamic via the adapter.dispatch and then namespace references. Also, this will need to be a breaking change. See my notes below.
macros/convert_values.sql
Outdated
{% macro convert_values(field_name, divide_by=100.0, divide_var=var('stripe__convert_values',false), alias=None) %} | ||
{% if divide_var %} | ||
{{ field_name }} / {{ divide_by }} as {{ alias if alias else field_name }} | ||
{% else %} | ||
{{ field_name }} as {{ alias if alias else field_name }} | ||
{% endif %} | ||
{% endmacro %} |
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.
I apologize for not catching this earlier, but we should add the adapter dispatch here in case users ever need to override this while also allowing there to not be any issues if customers have macros with the same name in their own projects (which is likely with a macro named convert_values
).
Can you update this to resemble the following structure seen here. Essentially adding the dispatch and then having the default version.
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.
yes!
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.
updated the macro, let me know if you have any questions
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
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.
LGTM!
@@ -14,7 +14,7 @@ models: | |||
tests: | |||
- not_null | |||
- name: amount | |||
description: Gross amount of the transaction, in cents. | |||
description: Gross amount of the transaction. "{{ doc('convert_values') }}" |
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.
I've never thought of using doc
blocks in this way, neat!
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.
LGTM
PR Overview
This PR will address the following Issue/Feature: fivetran/dbt_stripe#100
This PR will result in the following new package version: v0.13.0
Breaking change as customers using only the staging models will experience changes in values in currency-related fields.Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:
Breaking Change
To disable this default conversion, refer to the README on disabling the
stripe__amount_divide
variable.PR Checklist
Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
Before marking this PR as "ready for review" the following have been applied:
Detailed Validation
Please share any and all of your validation steps:
See validation link in internal ticket
If you had to summarize this PR in an emoji, which would it be?
💃