Skip to content

Commit df22ed5

Browse files
joostboonclaude
andcommitted
feat: add show_sample_rows tag to override PII-based sample hiding
Adds a new tag mechanism that is the inverse of the existing PII tag behavior. When enable_samples_on_show_sample_rows_tags is true, models or columns tagged with show_sample_rows will have their samples shown even when PII tags would otherwise suppress them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7a2b542 commit df22ed5

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

macros/edr/materializations/test/test.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@
7676
{% endif %}
7777

7878
{% if disable_test_samples %} {% set sample_limit = 0 %}
79-
{% elif elementary.is_pii_table(flattened_test) %} {% set sample_limit = 0 %}
80-
{% elif elementary.should_disable_sampling_for_pii(flattened_test) %}
81-
{% set sample_limit = 0 %}
79+
{% elif not elementary.is_show_sample_rows_table(flattened_test) %}
80+
{% if elementary.is_pii_table(flattened_test) %} {% set sample_limit = 0 %}
81+
{% elif elementary.should_disable_sampling_for_pii(flattened_test) %}
82+
{% set sample_limit = 0 %}
83+
{% endif %}
8284
{% endif %}
8385

8486
{% set result_rows = elementary.query_test_result_rows(

macros/edr/system/system_utils/get_config_var.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@
143143
"anomaly_exclude_metrics": none,
144144
"disable_samples_on_pii_tags": false,
145145
"pii_tags": ["pii"],
146+
"enable_samples_on_show_sample_rows_tags": false,
147+
"show_sample_rows_tags": ["show_sample_rows"],
146148
"bigquery_disable_partitioning": false,
147149
"bigquery_disable_clustering": false,
148150
"upload_only_current_project_artifacts": false,

macros/edr/system/system_utils/get_pii_columns_from_parent_model.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,21 @@
3838
{% set column_nodes = parent_model.get("columns") %}
3939
{% if not column_nodes %} {% do return(pii_columns) %} {% endif %}
4040

41+
{% set enable_show_tags = elementary.get_config_var("enable_samples_on_show_sample_rows_tags") %}
42+
{% set raw_show_tags = elementary.get_config_var("show_sample_rows_tags") %}
43+
{% set show_tags = (
44+
(raw_show_tags if raw_show_tags is iterable else [raw_show_tags])
45+
| map("lower") | list
46+
) %}
47+
4148
{% for column_node in column_nodes.values() %}
4249
{% set all_column_tags_lower = elementary.get_column_tags(column_node) %}
4350

51+
{# Skip columns explicitly tagged to show sample rows (if feature is enabled) #}
52+
{% if enable_show_tags and elementary.lists_intersection(all_column_tags_lower, show_tags) | length > 0 %}
53+
{% continue %}
54+
{% endif %}
55+
4456
{% for pii_tag in pii_tags %}
4557
{% if pii_tag in all_column_tags_lower %}
4658
{% do pii_columns.append(column_node.get("name")) %} {% break %}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% macro is_show_sample_rows_table(flattened_test) %}
2+
{% if not elementary.get_config_var("enable_samples_on_show_sample_rows_tags") %}
3+
{% do return(false) %}
4+
{% endif %}
5+
6+
{% set raw_show_tags = elementary.get_config_var("show_sample_rows_tags") %}
7+
{% set show_tags = (
8+
(raw_show_tags if raw_show_tags is iterable else [raw_show_tags])
9+
| map("lower")
10+
| list
11+
) %}
12+
13+
{% set raw_model_tags = elementary.insensitive_get_dict_value(
14+
flattened_test, "model_tags", []
15+
) %}
16+
{% set model_tags = (
17+
(raw_model_tags if raw_model_tags is iterable else [raw_model_tags])
18+
| map("lower")
19+
| list
20+
) %}
21+
22+
{% set intersection = elementary.lists_intersection(model_tags, show_tags) %}
23+
{% do return(intersection | length > 0) %}
24+
{% endmacro %}

0 commit comments

Comments
 (0)