<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to import SqlDWRelation from com.databricks.spark.sqldw in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34220#M24990</link>
    <description>&lt;P&gt;Have you tried to pass as simple query to Synapse to see if that works?&lt;/P&gt;</description>
    <pubDate>Tue, 30 Nov 2021 09:07:47 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2021-11-30T09:07:47Z</dc:date>
    <item>
      <title>How to import SqlDWRelation from com.databricks.spark.sqldw</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34218#M24988</link>
      <description>&lt;P&gt;Hello, All - I'm working on a project using the SQL DataWarehouse connector built into Databricks (&lt;A href="https://docs.databricks.com/data/data-sources/azure/synapse-analytics.html" alt="https://docs.databricks.com/data/data-sources/azure/synapse-analytics.html" target="_blank"&gt;https://docs.databricks.com/data/data-sources/azure/synapse-analytics.html&lt;/A&gt;). From there, I'm trying to &lt;B&gt;extract information from the logical plan / logical relation which will help me identify the table and database &lt;/B&gt;(or at least JDBC URL) that is being used to query the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I need to &lt;B&gt;cast from BaseRelation to SqlDWRelation &lt;/B&gt;after extracting the relation from the logical plan as seen below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;val df = spark.read.format("com.databricks.spark.sqldw")
.option("url", sqlDwUrl)
.option("tempDir", tempDir)
.option("forwardSparkAzureStorageCredentials", "true")
.option("dbTable", tableName)
.load()
val logicalPlan = df.queryExecution.logical
val logicalRelation = logicalPlan.asInstanceOf[LogicalRelation]
val sqlBaseRelation = logicalRelation.relation&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, after doing so, I try to cast `sqlBaseRelation.asInstanceOf[SqlDWRelation]` and it &lt;B&gt;results in an error &lt;/B&gt;that looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;object SqlDWRelation in package sqldw cannot be accessed in package com.databricks.spark.sqldw&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Edit&lt;/B&gt;: The above error makes sense since it's a private class &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When looking at the jar provided in the workspace for the SQL DW connector, I can see SqlDWRelation as a (edit &lt;S&gt;public&lt;/S&gt; ) private class &lt;S&gt;but it's not available via tab / autocomplete inside a Databricks Notebook&lt;/S&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone here ever attempted to work with a SqlDWRelation and extract information about the table and database names for the given logicalrelation? Thank you for any guidance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my environment, I'm using:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Azure Databricks&lt;/LI&gt;&lt;LI&gt;Databricks Runtime 9.1&lt;/LI&gt;&lt;LI&gt;Scala Notebook&lt;/LI&gt;&lt;LI&gt;Azure Synapse SQL Pools&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 30 Nov 2021 05:02:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34218#M24988</guid>
      <dc:creator>WillJMSFT</dc:creator>
      <dc:date>2021-11-30T05:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to import SqlDWRelation from com.databricks.spark.sqldw</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34220#M24990</link>
      <description>&lt;P&gt;Have you tried to pass as simple query to Synapse to see if that works?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 09:07:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34220#M24990</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-11-30T09:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to import SqlDWRelation from com.databricks.spark.sqldw</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34221#M24991</link>
      <description>&lt;P&gt;@Werner Stinckens​&amp;nbsp; Thanks for the reply! The SQL DW Connector itself is working just fine and I can retrieve the results from the SQL DW.  I'm trying to extract the metadata (i.e. the Server, Database, and Table name) from the logical plan (or through any other means).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 13:57:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34221#M24991</guid>
      <dc:creator>WillJMSFT</dc:creator>
      <dc:date>2021-11-30T13:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to import SqlDWRelation from com.databricks.spark.sqldw</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34222#M24992</link>
      <description>&lt;P&gt;Lol so I was typing a response but now I see you edited your post.&lt;/P&gt;&lt;P&gt;A private method cannot be called indeed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I worked with the connector but only to run queries and such, not to fetch metadata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the golden rule is: if autocomplete shows it, you can use it.&lt;/P&gt;&lt;P&gt;Maybe with a lot of effort because of missing docs, but it can be done.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 15:56:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34222#M24992</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-11-30T15:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to import SqlDWRelation from com.databricks.spark.sqldw</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34223#M24993</link>
      <description>&lt;P&gt;Ah!  Yes! Sorry about that! I realized this morning that it was a private class and that's why I wasn't seeing it show up in autocomplete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next step is to figure out how we can still access that data even when it's using a BaseRelation and not just the (private) SqlDWRelation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really appreciate your replies, @werners!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 16:01:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34223#M24993</guid>
      <dc:creator>WillJMSFT</dc:creator>
      <dc:date>2021-11-30T16:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to import SqlDWRelation from com.databricks.spark.sqldw</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34224#M24994</link>
      <description>&lt;P&gt;Hi @Will Johnson​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If @Werner Stinckens​&amp;nbsp;'s reply helped you to solved this issue, could you select it as best response? it will help to move it to the top.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 00:06:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-sqldwrelation-from-com-databricks-spark-sqldw/m-p/34224#M24994</guid>
      <dc:creator>jose_gonzalez</dc:creator>
      <dc:date>2021-12-01T00:06:50Z</dc:date>
    </item>
  </channel>
</rss>

