alter DLT Materialized View alter column set MASK

kranthi2
New Contributor III

I am trying to mask a column on a DLT materialized view - this is created using DLT syntax. I am not able set the column masking after creation. Appreciate any workaround.

alter DLT Materialized View alter column set MASK

lucasrocha
Databricks Employee
Databricks Employee

Hello @kranthi2 , I hope you're doing well.

It seems that this command won't work for MVs, as it expected table. When trying to run the following command, for example:

ALTER TABLE `catalog`.`schema`.`MV` ALTER COLUMN column_ SET MASK mask_func;
We get the following error:
[EXPECT_TABLE_NOT_VIEW.NO_ALTERNATIVE] 'ALTER TABLE ... ALTER COLUMN' expects a table but `catalog`.`schema`.`MV` is a view. SQLSTATE: 42809
 
Also, if you go to the table through Catalog, and follow the docs steps:
lucasrocha_0-1725661412591.png

Doc.: https://docs.databricks.com/en/tables/row-and-column-filters.html#apply-a-column-mask

In a MV, you will face the following message:
To add or remove column mask for Materialized Views, use the CREATE OR REPLACE statement

Which indicates that, for now, this operation is not possible for MVs.

If you believe this feature of adding column mask to MVs through ALTER TABLE/VIEW would be beneficial, you could submit an idea in Databricks' Ideas Portal.

Best regards,
Lucas Rocha
Technical Solutions Engineer

View solution in original post

kranthi2
New Contributor III

Thank you. I will submit the idea.