skip to Main Content

I am trying to write to Snowflake using Snowpark from Azure Databricks and I get the following error. This error does not seem related to Unity Catalog but some configuration. I have made sure I have imported required libraries.

df_new.write.mode("append").saveAsTable("MyTableName")

Error: AnalysisException: [UC_NOT_ENABLED] Unity Catalog is not enabled on this cluster.

ADB Runtime: 13.3LTS ML
Python: 3.10.12

2

Answers


  1. Chosen as BEST ANSWER

    As I suspected, it had nothing to do with Unity Catalog. I need to create a Snowpark dataframe from my pandas dataframe to use its write method. This solved my problem.

    #Incorrect
    df_new.write.mode("append").saveAsTable("MyTableName")
    
    #Correct
    new_session.create_dataframe(df_new).write.mode("append").saveAsTable("MyTableName")
    

    where new_session is the snowpark session.

    The error was misleading.


  2. As per MS Document

    To create a cluster that can access Unity Catalog, the workspace you are creating the cluster in must be attached to a Unity Catalog metastore and must use a Unity-Catalog-capable access mode (shared or single user).

    As per error message It’s required that the cluster you are using should have unity catalog enabled then you will be able to query your catalog. After enabling unity catalog run USE CATALOG my_catalog; command to use it.

    You can follow this document to enable Unity catalog. After enabling it, execute your commands it will get succeeded.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search