-
Notifications
You must be signed in to change notification settings - Fork 22
[Bug] DBT --empty flag not supported. #123
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the issue
Currently, calling dbt build --empty on a model that is using the sfdc_formula_view results in a model run failure and dbt is unable to build a model out of the formula view.
Relevant error log or model output
(dbt-prod) C:\Users\jgreen\git\bidw-dbt\DBT>dbt build --select frm_fox_account_vw --empty
Created invocation id e604bd07-7ab1-4c57-bde2-1d76d19f02c7
22:53:17 Cloud CLI invocation created: e604bd07-7ab1-4c57-bde2-1d76d19f02c7
22:53:19 Running dbt...
22:53:19 Unable to do partial parsing because a project config has changed
22:53:19 Unable to do partial parsing because a project config has changed
22:53:49 Found 4152 models, 276 snapshots, 7061 data tests, 14 seeds, 4 operations, 1399 sources, 1391 macros
22:53:50
22:53:50 Concurrency: 8 threads (target='dev')
22:53:50
22:54:07 Found 4152 models, 276 snapshots, 7061 data tests, 14 seeds, 4 operations, 1399 sources, 1391 macros
22:54:18 1 of 2 START hook: DBT.on-run-start.0 .......................................... [RUN]
22:54:20 1 of 2 OK hook: DBT.on-run-start.0 ............................................. [OK in 1.38s]
22:54:20 2 of 2 START hook: DBT.on-run-start.1 .......................................... [RUN]
22:54:26 2 of 2 OK hook: DBT.on-run-start.1 ............................................. [OK in 6.11s]
22:54:26
22:54:26 1 of 1 START sql view model dbt_abigail.frm_fox_account_vw ..................... [RUN]
22:54:29 1 of 1 ERROR creating sql view model dbt_abigail.frm_fox_account_vw ............ [ERROR in 2.90s]
22:54:29
22:54:29 1 of 2 START hook: DBT.on-run-end.0 ............................................ [RUN]
22:54:29 1 of 2 OK hook: DBT.on-run-end.0 ............................................... [OK in 0.00s]
22:54:29 Running dbt Constraints
22:58:29 Finished dbt Constraints
22:58:29 2 of 2 START hook: dbt_constraints.on-run-end.1 ................................ [RUN]
22:58:29 2 of 2 OK hook: dbt_constraints.on-run-end.1 ................................... [OK in 240.50s]
22:58:30
22:58:30 Finished running 4 project hooks, 1 view model in 0 hours 4 minutes and 39.91 seconds (279.91s).
22:58:35
22:58:35 Completed with 1 error, 0 partial successes, and 0 warnings:
22:58:35
22:58:35 Failure in model frm_fox_account_vw (models/snapshot_intermediates/fox/frm_fox_views/frm_fox_account_vw.sql)
22:58:35 Database Error in model frm_fox_account_vw (models/snapshot_intermediates/fox/frm_fox_views/frm_fox_account_vw.sql)
001003 (42000): SQL compilation error:
syntax error line 13 at position 4 unexpected ')'.Here's the compiled model:
-- depends_on: (select * from dw_landing_db.fox.account where false limit 0)
-- Best practice for this model is to be materialized as view. That is why we have set that here.
-- Raise a warning if users are trying to use full_statement_version=false. We are keeping the variable in the macro, however, since we don't want errors if they previously set it to true.
Expected behavior
DBT builds the view with 0 rows as expected.
https://docs.getdbt.com/docs/build/empty-flag
Possible solution
I have a potential solution in a fork located here: https://github.com/paperlinguist/dbt_salesforce_formula_utils/blob/main/macros/sfdc_formula_view.sql
I have tested it with and without the --empty and not empty flag and it seems to behave well but I am unable to test it outside of Snowflake.
We're likely going to deploy this to prod on our side by replacing the macro but I thought I'd share here in case the solution is worth it. It's fairly different from the original macro because it's running an actual query instead of relying on dbt to return the column values. That being said, it doesn't add significantly to the execution time.
dbt Project configurations
We have a non-standard source configuration to enable us to allow deleted records through into our final views but it should be unrelated to the issue at hand. Here's the ddl:
create or replace view FIVETRAN_FORMULA_MODEL_VW(
OBJECT,
MODEL,
_FIVETRAN_SYNCED
) as (
select
object,
regexp_replace(model, 'WHERE NOT mt.\"_FIVETRAN_DELETED\"', '') as model,
_fivetran_synced
from
dw_landing_db.fox.fivetran_formula_model
);
And is overriding the default in the src yaml:
- name: fivetran_formula_model
description: "This is a hotfix to remove hard-coded fivetran criteria that removes deleted rows before we can snapshot them."
identifier: fivetran_formula_model_vw
- name: disabled_fivetran_formula_model
description: ""
identifier: fivetran_formula_model
config:
enabled: false
columns:
- name: object
data_type: varchar
description: ""
- name: model
data_type: varchar
description: ""
- name: _fivetran_synced
data_type: timestamp_tz
description: ""
Package versions
22:44:11 Running dbt...
22:44:12 Installing godatadriven/dbt_date
22:44:12 Installed from version 0.16.1
22:44:12 Up to date!
22:44:12 Installing metaplane/dbt_expectations
22:44:12 Installed from version 0.10.9
22:44:12 Up to date!
22:44:12 Installing Snowflake-Labs/dbt_constraints
22:44:12 Installed from version 1.0.6
22:44:12 Up to date!
22:44:12 Installing get-select/dbt_snowflake_query_tags
22:44:12 Installed from version 2.5.3
22:44:12 Up to date!
22:44:12 Installing fivetran/salesforce_formula_utils
22:44:13 Installed from version 0.10.0
22:44:13 Up to date!
22:44:13 Installing brooklyn-data/dbt_artifacts
22:44:13 Installed from version 2.9.3
22:44:13 Up to date!
22:44:13 Installing dbt-labs/dbt_project_evaluator
22:44:13 Installed from version 1.1.2
22:44:13 Up to date!
22:44:13 Installing fivetran/fivetran_utils
22:44:13 Installed from version 0.4.10
22:44:13 Up to date!
22:44:13 Installing dbt-labs/dbt_utils
22:44:13 Installed from version 1.3.1
22:44:13 Up to date!
What database are you using dbt with?
snowflake
How are you running this dbt package?
dbt Cloud™
dbt Version
dbt Latest (Formerly known as Versionless)
executed from:
dbt Cloud CLI - 0.40.6 (9a60418f8facddea30757f869b37a854711e0fe7 2025-09-09T15:05:30Z)
Additional Context
No response
Are you willing to open a PR to help address this issue?
- Yes.
- Yes, but I will need assistance.
- No.