Forum Discussion
Extract Data from Databricks Unity Catalog
- 2 years ago
I found a solution to my previous mentioned problem. The connection from Fabric Notebook to Databricks Unity Catalog is now working as expected - but not as described initially by Microsoft Documentation.
What I did now - in case anybody meets the same issue:1. Download the Databricks JDBC Driver and store the .jar to Fabric Lakehouse.
2. Create a custom environment in Fabric
3. Add a spark property for spark.jars that is pointing to the ABFSS location of the uploaded .jar file:
4. In the Notebook itself, connect to this custom environment and use this call for reading the data:personal_access_token = "XXX" jdbc_url = "jdbc:databricks://adb-XXX.azuredatabricks.net:443/default" http_path = "sql/protocolv1/o/XXX/XXX" query = "[catalog].[schema].[table]" # or "(SELECT [selection] FROM [table]) as alias" df = (spark.read.format("jdbc") .option("url", jdbc_url) .option("dbtable", query) .option("user", "token") .option("password", personal_access_token) .option("driver", "com.databricks.client.jdbc.Driver") .option("ssl", "1") .option("ThriftTransport", "2") .option("AuthMech", "3") .option("httpPath", http_path) .option("UseNativeQuery", "0") .load())The option "UseNativeQuery" is necessary too. Otherwise the jdbc dialect seems to be wrong, causing the before mentioned issue with data types (+ issues with quotes).
Thanks v-cboorla-msft for your help.
Recently there is release of built-in support for integrating UC DB Tables into Fabric. It is much easier to integrate
https://learn.microsoft.com/en-us/fabric/database/mirrored-database/azure-databricks