a week ago
While trying to develop metric view in databricks, I encountered with below error.
I am using a pii view toget a column to build my final metric view, this is blocking on having the materialization to metric view because of masking functions used while building the pii view, without materialization any query on metric view is being timed out.
I know there is a limitation "Materialization Doesn’t Support Column Masking and Row-Level Security" but are there any workarounds on this? Because as metric views will be build using multiple semantic views and avoiding pii views will be inevitable when working in enterprise level.
a week ago
Hello @Avinash_Narala, I took a look at both internal and external documentation and here is what I found.
What you're seeing is by design. A materialization is computed once, under the owner's identity, and then served to everyone. If the source returns different values depending on who's asking, the stored result would either leak the clear value or show the wrong one. Your screenshot shows METRIC_VIEW_MATERIALIZATION_WITH_INVOKER_DEPENDENT_EXPRESSIONS_NOT_SUPPORTED, which fires when anything in the dependency chain uses functions like current_user() or is_account_group_member(). Row filters, column masks, and ABAC policies on the sources are blocked for the same reason. Masking the metric view itself isn't possible either: views don't accept column masks, and ABAC policies can't target metric views.
So there's no switch for this. The fix is moving the masking to a different layer:
MEASURE() and a fixed set of dimensions, so you need one per query shape. Run EXPLAIN EXTENDED to confirm queries through the wrapper still hit the materialization.SELECT grants.MASK clause. The mask is still enforced per user at query time. One caveat: a materialized view over sources that carry row filters or column masks always does a full refresh.A wrapper for the second option looks like this:
CREATE OR REPLACE VIEW catalog.schema.sales_secure AS
WITH agg AS (
SELECT region, customer_email, MEASURE(total_revenue) AS total_revenue
FROM catalog.schema.sales_metric_view
GROUP BY ALL
)
SELECT
region,
CASE WHEN is_account_group_member('pii_readers') THEN customer_email ELSE '***' END AS customer_email,
total_revenue
FROM agg;
For the timeouts in the meantime, check the query profile to see where the time goes, and consider a larger SQL warehouse.
References:
If you found this answer helpful please check off "Accept as Solutions" so that others can have confidence in the answer.
Regards, Louis.
yesterday
CREATE VIEW per source that points directly at the base table, excluding or hashing PII columns, and bypassing the masking layer entirely. Your existing masked views stay untouched for all current consumers. You don't need to rebuild your entire view layer then.a week ago
Hello @Avinash_Narala, I took a look at both internal and external documentation and here is what I found.
What you're seeing is by design. A materialization is computed once, under the owner's identity, and then served to everyone. If the source returns different values depending on who's asking, the stored result would either leak the clear value or show the wrong one. Your screenshot shows METRIC_VIEW_MATERIALIZATION_WITH_INVOKER_DEPENDENT_EXPRESSIONS_NOT_SUPPORTED, which fires when anything in the dependency chain uses functions like current_user() or is_account_group_member(). Row filters, column masks, and ABAC policies on the sources are blocked for the same reason. Masking the metric view itself isn't possible either: views don't accept column masks, and ABAC policies can't target metric views.
So there's no switch for this. The fix is moving the masking to a different layer:
MEASURE() and a fixed set of dimensions, so you need one per query shape. Run EXPLAIN EXTENDED to confirm queries through the wrapper still hit the materialization.SELECT grants.MASK clause. The mask is still enforced per user at query time. One caveat: a materialized view over sources that carry row filters or column masks always does a full refresh.A wrapper for the second option looks like this:
CREATE OR REPLACE VIEW catalog.schema.sales_secure AS
WITH agg AS (
SELECT region, customer_email, MEASURE(total_revenue) AS total_revenue
FROM catalog.schema.sales_metric_view
GROUP BY ALL
)
SELECT
region,
CASE WHEN is_account_group_member('pii_readers') THEN customer_email ELSE '***' END AS customer_email,
total_revenue
FROM agg;
For the timeouts in the meantime, check the query profile to see where the time goes, and consider a larger SQL warehouse.
References:
If you found this answer helpful please check off "Accept as Solutions" so that others can have confidence in the answer.
Regards, Louis.
Wednesday
@Louis_Frolio Thanks for the reply.
I agree with you that metric views should be built on de-identified table/view. But coming to our situation we already have a whole lot of views over the years till now and this metric view concept is new as you know. So, If we want to utilize this feature and create metric views on top of existing view isn't there any workaround instead of building a whole lot of de-identified table/view from scratch?
yesterday
CREATE VIEW per source that points directly at the base table, excluding or hashing PII columns, and bypassing the masking layer entirely. Your existing masked views stay untouched for all current consumers. You don't need to rebuild your entire view layer then.