Hi all :wave:, Cross-posting for more visibility....
# community-support
m
Hi all 👋, Cross-posting for more visibility. I have the same issue mentioned here. I work on integrating
--defer
combined with
--favor-state
to improve my development workflow. The issue is that Elementary tries to write in prod database for Elementary models instead of targeting sandbox. Does anyone know how to fix this? The command is
dbt build -s "state:modified.body" --defer --state prod-state --favor-state
. The expected behaviour is: • Run only what changed in my project compared to latest production state • When compiling the SQL model to run, target production dependencies instead of local ones • Elementary runs whatever models/posthook in my sandbox. What it does: • Run only what changed in my project compared to latest production state • When compiling the SQL model to run, target production dependencies instead of local ones • Elementary runs whatever models/posthook in production environment which I don't have access Thanks 🙏
Copy code
### With --var  --vars '{"disable_dbt_artifacts_autoupload": true,"disable_run_results":true, "disable_tests_results":true, "disable_dbt_invocation_autoupload":true}'

16:00:17  Completed with 4 errors and 0 warnings:
16:00:17  
16:00:17    Database Error in test elementary_schema_changes_from_baseline_organizations_False__True (models/core/_core__models.yml)
  003001 (42501): SQL access control error:
  Insufficient privileges to operate on schema 'ELEMENTARY'
16:00:17  
16:00:17    Database Error in test elementary_volume_anomalies_organizations_ (models/core/_core__models.yml)
  003001 (42501): SQL access control error:
  Insufficient privileges to operate on schema 'ELEMENTARY'
16:00:17  
16:00:17    Database Error in model information_schema_columns (models/edr/dbt_artifacts/information_schema_columns.sql)
  002003 (42S02): SQL compilation error:
  Object 'DERIVED.ELEMENTARY.DBT_MODELS' does not exist or not authorized.
16:00:17  
16:00:17    on-run-end failed, error:
 003001 (42501): SQL access control error:
Insufficient privileges to operate on table 'DATA_MONITORING_METRICS'
16:00:17  
16:00:17  Done. PASS=14 WARN=0 ERROR=4 SKIP=1 TOTAL=19

### With --exclude "elementary.*"

16:05:23    on-run-end failed, error:
 003001 (42501): SQL access control error:
Insufficient privileges to operate on table 'DATA_MONITORING_METRICS'
16:05:23  
16:05:23  Done. PASS=13 WARN=0 ERROR=1 SKIP=0 TOTAL=14
More details on my setup • dbt core version
1.6.14
• Elementary package version
0.15.2
With `--vars '{"disable_dbt_artifacts_autoupload": true,"disable_run_results":true, disable_tests_results":"true, "disable_dbt_invocation_autoupload":true}'`: • Still runs Elementary models ❌ • Still runs post hook ❌ With
--vars '{"disable_dbt_artifacts_autoupload": true,"disable_run_results":true, disable_tests_results":"true, "disable_dbt_invocation_autoupload":true}' --exclude "elementary.*"
• Does not run Elementary models ✅ • Still runs post hook ❌ With
--vars '{"elementary_enabled": false}'
• Still runs Elementary models ❌ • Still runs post hook ❌