Skip to content

Commit 78c7d7e

Browse files
committed
address comments
1 parent ecc46d5 commit 78c7d7e

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

dbt/include/databricks/macros/relations/components/column_mask.sql

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,12 @@
1313
column_name,
1414
mask_name,
1515
using_columns
16-
FROM `{{ relation.database|lower }}`.information_schema.column_masks
16+
FROM `system`.`information_schema`.`column_masks`
1717
WHERE table_catalog = '{{ relation.database|lower }}'
1818
AND table_schema = '{{ relation.schema|lower }}'
1919
AND table_name = '{{ relation.identifier|lower }}';
2020
{%- endmacro -%}
2121

22-
{% macro apply_column_masks_from_model_columns(relation) -%}
23-
{% if relation.is_hive_metastore() %}
24-
{{ exceptions.raise_compiler_error("Column masks are not supported for Hive Metastore") }}
25-
{%- endif %}
26-
{{ log("Applying column masks from model to relation " ~ relation) }}
27-
{% set columns = model.get('columns', {}) %}
28-
{% for column_name, column_def in columns.items() %}
29-
{% if column_def is mapping and column_def.get('column_mask') %}
30-
{%- call statement('main') -%}
31-
{{ alter_set_column_mask(relation, column_name, column_def.column_mask) }}
32-
{%- endcall -%}
33-
{% endif %}
34-
{% endfor %}
35-
{%- endmacro -%}
36-
3722
{% macro apply_column_masks(relation, column_masks) -%}
3823
{% if relation.is_hive_metastore() %}
3924
{{ exceptions.raise_compiler_error("Column masks are not supported for Hive Metastore") }}
@@ -56,13 +41,13 @@
5641
{%- endmacro -%}
5742

5843
{% macro alter_drop_column_mask(relation, column) -%}
59-
ALTER TABLE {{ relation.render() }}
44+
ALTER {{ relation.type }} {{ relation.render() }}
6045
ALTER COLUMN {{ column }}
6146
DROP MASK;
6247
{%- endmacro -%}
6348

6449
{% macro alter_set_column_mask(relation, column, mask) -%}
65-
ALTER TABLE {{ relation.render() }}
50+
ALTER {{ relation.type }} {{ relation.render() }}
6651
ALTER COLUMN {{ column }}
6752
SET MASK {{ mask.function }}
6853
{%- if mask.using_columns %}

dbt/include/databricks/macros/relations/materialized_view/create.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% macro databricks__get_create_materialized_view_as_sql(relation, sql) -%}
2-
{# Column masks result in silent failure for materialized views, so throw custom compiler error #}
2+
{# Column masks are supported in DBSQL, but not yet wired up to the adapter. Return a helpful error until supported. #}
33
{% if column_mask_exists() %}
4-
{% do exceptions.raise_compiler_error("Column masks are not supported for materialized views. Column '" ~ column_name ~ "' has a mask defined.") %}
4+
{% do exceptions.raise_compiler_error("Column masks are not supported for materialized views.") %}
55
{% endif %}
66
{%- set materialized_view = adapter.get_config_from_model(config.model) -%}
77
{%- set partition_by = materialized_view.config["partition_by"].partition_by -%}

dbt/include/databricks/macros/relations/view/create.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% macro databricks__create_view_as(relation, sql) %}
2-
{# Column masks result in silent failure for views, so throw custom compiler error #}
2+
{# Column masks are supported in DBSQL, but not yet wired up to the adapter. Return a helpful error until supported. #}
33
{% if column_mask_exists() %}
4-
{% do exceptions.raise_compiler_error("Column masks are not supported for views. Column '" ~ column_name ~ "' has a mask defined.") %}
4+
{% do exceptions.raise_compiler_error("Column masks are not supported for views.") %}
55
{% endif %}
66
{{ log("Creating view " ~ relation) }}
77
create or replace view {{ relation.render() }}

0 commit comments

Comments
 (0)