Error occurs on create materialized view with spark.sql

donlxz
Databricks Partner

When creating materialized view with spark.sql function it returns following error message.

[MATERIALIZED_VIEW_OPERATION_NOT_ALLOWED.MV_NOT_ENABLED] The materialized view operation CREATE is not allowed: Materialized view features are not enabled for your workspace. Please reach out to Databricks to enable materialized views for your workspace. SQLSTATE: 56038

But I can create materialized view with sql editor, I have create materialized view permission on target catalog and schema.

Is this a known issue with spark.sql ?

szymon_dybczak
Esteemed Contributor III

Hi @donlxz ,

When you look at documentation, they only available way to create materialized view is by executing CREATE MATERIALIZED VIEW statement. You can submit that statement via SQL editor, Azure Databricks UI, Databricsk CLI or Databricks SQL API. 

szymon_dybczak_0-1760449975337.png

 

Use materialized views in Databricks SQL - Azure Databricks | Microsoft Learn

So, you can't create materialized view wiht spark.sql approach.

View solution in original post

donlxz
Databricks Partner

Hi, @szymon_dybczak 

Thank you for your response.
You're right, it was mentioned in the documentation—I missed it when checking.
I understand now that it's not possible to do this with spark.sql. Thanks for clarifying!