<?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: dbutils conflicts with a custom spark extension in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8242#M3935</link>
    <description>&lt;P&gt;Hello @Yuan Gao​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Databricks, spark and dbutils are automatically injected only into the main entrypoint - your notebook, but they aren't propagated to the Python modules. With spark solution is easy, just use the getActiveSession function of SparkSession class (as SparkSession.getActiveSession()), but you need to continue to pass dbutils explicitly until you don't abstract getting dbutils into some function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;A href="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" alt="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" target="_blank"&gt;documentation for &lt;/A&gt;&lt;A href="https://docs.databricks.com/dev-tools/databricks-connect.html#access-dbutils" alt="https://docs.databricks.com/dev-tools/databricks-connect.html#access-dbutils" target="_blank"&gt;Databricks Connect&lt;/A&gt;&lt;A href="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" alt="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" target="_blank"&gt; shows an example&lt;/A&gt;&amp;nbsp;of how it could be achieved. That example has&amp;nbsp;SparkSession as an explicit parameter, but it could be modified to avoid that completely, with something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def get_dbutils():
  from pyspark.sql import SparkSession
  spark = SparkSession.getActiveSession()
  if spark.conf.get("spark.databricks.service.client.enabled") == "true":
    from pyspark.dbutils import DBUtils
    return DBUtils(spark)
  else:
    import IPython
    return IPython.get_ipython().user_ns["dbutils"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and then in your function, you can use the main function to get the spark dbutils functionality&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2023 09:28:14 GMT</pubDate>
    <dc:creator>Tayyab_Vohra</dc:creator>
    <dc:date>2023-03-06T09:28:14Z</dc:date>
    <item>
      <title>dbutils conflicts with a custom spark extension</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8241#M3934</link>
      <description>&lt;P&gt;Hello dear community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we have installed a custom spark extension to filter the files allowed to be read into the notebook. It was all good if we use the spark functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the files are not filtered properly if the user would use e.g., dbutils.fs.cp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone has an idea why dbutils does not consider the spark extension in this scenario? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 21:42:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8241#M3934</guid>
      <dc:creator>maaaxx</dc:creator>
      <dc:date>2023-03-05T21:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: dbutils conflicts with a custom spark extension</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8242#M3935</link>
      <description>&lt;P&gt;Hello @Yuan Gao​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Databricks, spark and dbutils are automatically injected only into the main entrypoint - your notebook, but they aren't propagated to the Python modules. With spark solution is easy, just use the getActiveSession function of SparkSession class (as SparkSession.getActiveSession()), but you need to continue to pass dbutils explicitly until you don't abstract getting dbutils into some function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;A href="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" alt="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" target="_blank"&gt;documentation for &lt;/A&gt;&lt;A href="https://docs.databricks.com/dev-tools/databricks-connect.html#access-dbutils" alt="https://docs.databricks.com/dev-tools/databricks-connect.html#access-dbutils" target="_blank"&gt;Databricks Connect&lt;/A&gt;&lt;A href="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" alt="https://docs.databricks.com/dev-tools/databricks-connect.html?&amp;amp;_ga=2.1065010.2028928120.1678084502-104607010.1676897071#access-dbutils" target="_blank"&gt; shows an example&lt;/A&gt;&amp;nbsp;of how it could be achieved. That example has&amp;nbsp;SparkSession as an explicit parameter, but it could be modified to avoid that completely, with something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def get_dbutils():
  from pyspark.sql import SparkSession
  spark = SparkSession.getActiveSession()
  if spark.conf.get("spark.databricks.service.client.enabled") == "true":
    from pyspark.dbutils import DBUtils
    return DBUtils(spark)
  else:
    import IPython
    return IPython.get_ipython().user_ns["dbutils"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and then in your function, you can use the main function to get the spark dbutils functionality&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 09:28:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8242#M3935</guid>
      <dc:creator>Tayyab_Vohra</dc:creator>
      <dc:date>2023-03-06T09:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: dbutils conflicts with a custom spark extension</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8244#M3937</link>
      <description>&lt;P&gt;Hi @Yuan Gao​,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Checking in. If @tayyab vohra​'s answer helped, would you let us know and mark the answer as best? If not, would you be happy to give us more information?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 10:08:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8244#M3937</guid>
      <dc:creator>Vartika</dc:creator>
      <dc:date>2023-04-03T10:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: dbutils conflicts with a custom spark extension</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8245#M3938</link>
      <description>This is the best answer. Thank you.

Am Mo., 3. Apr. 2023 um 12:08 Uhr schrieb Databricks Community &amp;lt;
community@databricks.com&amp;gt;:</description>
      <pubDate>Mon, 10 Apr 2023 13:09:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8245#M3938</guid>
      <dc:creator>maaaxx</dc:creator>
      <dc:date>2023-04-10T13:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: dbutils conflicts with a custom spark extension</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8243#M3936</link>
      <description>&lt;P&gt;Hi, could you please explain a little more about the custom spark extension?&lt;/P&gt;&lt;P&gt;Also please tag&amp;nbsp;&lt;A href="https://community.databricks.com/s/profile/0053f000000WWwvAAG" alt="https://community.databricks.com/s/profile/0053f000000WWwvAAG" target="_blank"&gt;@Debayan&lt;/A&gt;​&amp;nbsp;with your next response which will notify me, Thank you! &lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 19:31:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-conflicts-with-a-custom-spark-extension/m-p/8243#M3936</guid>
      <dc:creator>Debayan</dc:creator>
      <dc:date>2023-03-06T19:31:39Z</dc:date>
    </item>
  </channel>
</rss>

