Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbt-snow-mask does not appear to honor quote: true #80

Open
jmkacz opened this issue Dec 18, 2024 · 0 comments
Open

dbt-snow-mask does not appear to honor quote: true #80

jmkacz opened this issue Dec 18, 2024 · 0 comments

Comments

@jmkacz
Copy link

jmkacz commented Dec 18, 2024

Does dbt-snow-mask honor the quote config (https://docs.getdbt.com/reference/resource-properties/quote) on at least the column?

I have collected the following information from one of our Analytics Engineers.

Situation:

  • We have no control over table or column naming upstream of the data warehouse.
  • The ETL system we use creates the tables in our data warehouse as they appear upstream.
  • There is an upstream database which uses periods in their column names.

models/_foo_source.yml

version: 2
sources:
  - name: foo
    database: "RAW" 
    schema: foo
    tables:
      - name: bar
        columns:
          - name: CONFIG.IDS.ORG.INSTITUTIONS.MANUALCONFIG
            quote: true
            meta:
              masking_policy: masking_policy_123

When we run dbt-snow-mask on the sources, we see the following error:

SQL compilation error:
syntax error line 2 at position 52 unexpected '.'.

Here is the query it attempted to run:

alter table RAW.foo.bar
                                modify column CONFIG.IDS.ORG.INSTITUTIONS.MANUALCONFIG
                                set masking policy  RAW.PUBLIC.masking_policy_123   force
/* {"app": "dbt", "dbt_snowflake_query_tags_version": "2.5.0", "dbt_version": "2024.12.12+0367206", "project_name": "dbt_amplify", "target_name": "PROD", "target_database": "TRANSFORMED", "target_schema": "_", "invocation_id": "85d61dd6-7f0c-4ed6-8b56-9c6307ed8819", "run_started_at": "2024-12-17T20:00:21.383722+00:00", "full_refresh": false, "which": "build", "dbt_cloud_project_id": "188744", "dbt_cloud_job_id": "262756", "dbt_cloud_run_id": "352734327", "dbt_cloud_run_reason_category": "scheduled", "dbt_cloud_run_reason": "scheduled"} */

We see the column name is not quoted.

Looking at the source code, it seems plausible that quoting is not honored. Though, that might be abstracted behind a function I am not seeing at the moment.

https://github.com/entechlog/dbt-snow-mask/blob/main/macros/snow-mask/apply-policy/apply_masking_policy_list_for_sources.sql#L66

I've traced the logic back to:

Here is what I pulled out of the manifest.json file:

jq '.sources."source.dbt_amplify.foo.bar".columns."CONFIG.IDS.ORG.INSTITUTIONS.MANUALCONFIG"' manifest.json
{
  "name": "CONFIG.IDS.ORG.INSTITUTIONS.MANUALCONFIG",
  "meta": {
    "masking_policy": "masking_policy_123"
  },
  "data_type": null,
  "constraints": [],
  "quote": true,
  "tags": [],
  "granularity": null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant