feat(sfdc_formula_view): add query_engine inference and use run_query for non-Redshift adapters#136
Open
fivetran-jacklowery wants to merge 1 commit into
Conversation
… for non-Redshift adapters Adds an optional `query_engine` argument (with `salesforce_formula_query_engine` var fallback and adapter-based inference) so the macro correctly filters `fivetran_formula_model` by both object and query engine. Replaces `dbt_utils.get_column_values` on the non-Redshift path with a direct `run_query` call, avoiding `load_relation` existence checks that silently return None for Snowflake catalog-linked (Iceberg) sources even when direct SQL succeeds. Redshift model_large / SUPER behavior is preserved unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates
sfdc_formula_viewto select the generated formula model by query engine and avoid a relation-existence check that can fail for Snowflake catalog-linked databases.The Salesforce connector produces multiple rows in
fivetran_formula_modelfor the same Salesforce object — one per query engine. The previous macro filtered only by object and useddbt_utils.get_column_values, whoseload_relationcheck can returnNonefor catalog-linked (Iceberg/Managed Data Lake) sources even when direct SQL against the source succeeds.Changes:
query_engineargument tosfdc_formula_viewsalesforce_formula_query_engineproject var as a fallbacktarget.typeif neither is provided (snowflake→Snowflake,bigquery→BigQuery,databricks/spark→Databricks,redshift→Redshift, elseGeneric)dbt_utils.get_column_valueson the non-Redshift path with a directrun_querycall that filters by bothobjectandquery_enginemodel_large/ SUPER behavior unchangedmaterializationargument; documents that catalog-linked Snowflake databases requirematerialization='table'because view creation is unsupportedValidation
Smoke-tested against a Snowflake catalog-linked database backed by Fivetran Managed Data Lake using fivetran/dbt_snowflake_iceberg_writer:
dbt run --select smoke_salesforce_formula_account smoke_salesforce_formula_user_role # 2 pass, 0 failBoth models materialized as
BASE TABLErelations againstlowery_linked_writer.dbt_core_dev.Test plan
dbt parsepasses with updated macrodbt compile --select smoke_salesforce_formula_account smoke_salesforce_formula_user_rolepassesdbt run --select smoke_salesforce_formula_account smoke_salesforce_formula_user_rolepasses withmaterialization='table'on Snowflake catalog-linked databasequery_enginerows for same object selects adapter-specific row; explicitquery_engineoverride works; default adapter inference works🤖 Generated with Claude Code