fivetran / dbt_salesforce_formula_utils

Package containing dbt macros to help generate salesforce formula fields synced from Fivetran.
https://fivetran.github.io/dbt_salesforce_formula_utils/
Apache License 2.0
16 stars 18 forks source link

[Bug] Compiled SQL Syntax Error with full_statement_version=false #91

Closed corca closed 1 year ago

corca commented 1 year ago

Is there an existing issue for this?

Describe the issue

I'm running the following model using salesforce_formula_utils 0.9.0 with dbt Core 1.4.5 on Databricks and encountering a syntax error

{{ config(
  enabled=true
) }}

-- depends_on: {{ source('salesforce', 'service_appointment') }} 

{{ salesforce_formula_utils.sfdc_formula_view(
    source_table='service_appointment',
    full_statement_version=false,
    fields_to_include=['secondary_campaign_c']
    ) 
}}

Error:

[PARSE_SYNTAX_ERROR] Syntax error at or near 'as': missing ')'.(line 411, pos 158)

The compiled SQL is:

select 
  service_appointment__table.`id`, 
    ...
  service_appointment__table.`customer_cancel_request_received_by_c`, 
  view_sql_1.secondary_campaign_c 
from 
  `fivetran`.`salesforce`.`service_appointment` as service_appointment__table, 
  (
    select 
      main__table.id, 
      (
        opportunity__alias.secondary_campaign_c
      ) as secondary_campaign_c 
    from 
      `fivetran`.`salesforce`.``service_appointment as main__table 
      left join `fivetran`.`salesforce`.``opportunity as opportunity__alias on main__table.opportunity_c = opportunity__alias.id
  ) as view_sql_1 
where 
  service_appointment__table.id = view_sql_1.id

There are two syntax errors in this compilation:

`fivetran`.`salesforce`.``service_appointment as main__table
left join `fivetran`.`salesforce`.``opportunity as opportunity__alias

Relevant error log or model output

No response

Expected behavior

The compiled SQL should have the table name properly wrapped with backticks:

`fivetran`.`salesforce`.`service_appointment` as main__table
left join `fivetran`.`salesforce`.`opportunity` as opportunity__alias

dbt Project configurations

N/A

Package versions

packages:
  - package: data-mie/dbt_profiler
    version: 0.7.0
  - package: fivetran/salesforce_formula_utils
    version: 0.9.0
  - package: fivetran/google_ads_source
    version: 0.9.2
  - package: fivetran/google_ads
    version: 0.9.2

What database are you using dbt with?

databricks

dbt Version

1.4.5

Additional Context

No response

Are you willing to open a PR to help address this issue?

fivetran-reneeli commented 1 year ago

Hi @corca! Thanks for opening this ticket. We've updated the package with the fixes in this most recent release (v0.9.1), and as such will be closing this out. Let us know if there's anything else!