Closed rtol5 closed 1 year ago
Hi @rtol5 thanks so much for opening this bug!
I see what you are saying and interesting that this issue has not showed up for us before. I actually just checked our data in BigQuery and found this error does not occur. This seems to be because BigQuery is able to handle a coalesce statement with only one argument; whereas Snowflake in this case does not. Nevertheless, we will want to correct this within our package to ensure users on other warehouses do not experience the error you are seeing.
I believe the area that will need to be updated is the following section of the sage_intacct__ap_ar_enhanced model
I believe this should be able to be resolved by adding an else
statement to the conditionals to force a second argument to the coalesce, even if one is not needed such as in this case where the invoices are disabled.
coalesce(
{% if var('sage_intacct__using_bills', True) %} bill_id {% endif %}
{% if fivetran_utils.enabled_vars(vars=["sage_intacct__using_bills", "sage_intacct__using_invoices"]) %}
,
{% endif %}
{% if var('sage_intacct__using_invoices', True) %} invoice_id {% endif %}
, null) as document_id, --Notice the change here with the addition of the null.
This way a null
is added as the last argument in the coalesce. Therefore, if there is only one argument then a second will always be present. This should have no impact on the data as if the bill or invoice id are not present, it will be null regardless.
This small addition will need to be made in both coalesce statement. Once those are applied I feel that should do the trick to resolving your error! I noticed you are interested in contributing. If so, feel free to open a PR and make these small additions to the sage_intacct__ap_ar_enhanced
model. Once the PR is opened, I will happily review and work together to fold this into the next release. If you are no longer interested in contributing, my team and I can pick this up in our upcoming sprint (next week) and let you know once the update is rolled out. Let me know if you have any questions if you wish to contribute.
Thanks again for raising this to our team!
hey @fivetran-joemarkiewicz – first off, really appreciate the thorough response and overall super collaborative tone!
i had a pretty busy week last week and i was just about to respond that i could definitely create a PR, but I see that @fivetran-reneeli actually just created one yesterday 👏 . Love how elegantly that was fixed, btw.
Thank you both!
Hi @rtol5 , thank you for working with us on opening this up! We've added this update in our latest release. Closing this issue!
Is there an existing issue for this?
Describe the issue
Current behavior:
sage_intacct__ap_ar_enhanced.sql
fails if one ofsage_intacct__using_bills
andsage_intacct__using_invoices
is set to true but the other is falseOverview: I tried to run this dbt model. For our environment, we need to pull AP (
sage_intacct__using_bills
= true) but not AR (sage_intacct__using_invoices
= false).When testing,
sage_intacct__ap_ar_enhanced.sql
throws this error message: SQL compilation error: error line 84 at position 8 not enough arguments for function [COALESCE(AP_AR_ENHANCED.BILL_ID)], expected 2, got 1 compiled Code at target/run/sage_intacct/models/sage_intacct__ap_ar_enhanced.sqlThe coalesce function in this line expects 2 arguments, but my environment has the code compile to just 1 argument (
COALESCE(AP_AR_ENHANCED.BILL_ID)
).Relevant error log or model output
Expected behavior
The logic in the coalesce is updated so that scenarios like this one can succeed.
dbt Project configurations
vars: sage_intacct__using_invoices: false
Package versions
What database are you using dbt with?
snowflake
dbt Version
1.4
Additional Context
No response
Are you willing to open a PR to help address this issue?