<?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: Access same createorreplacetempview(&amp;quot;viewname&amp;quot;) by multiple functions. in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/access-same-createorreplacetempview-quot-viewname-quot-by/m-p/15959#M10209</link>
    <description>&lt;P&gt;there is two type of views&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one is global view - it will be available for whole cluster and notebook but it will removed after cluster restart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and another is Temp view- that will be available for only notebook level, and other notebook will not able to see that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you will get little bit idea on this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Aviral Bhardwaj&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 14:06:47 GMT</pubDate>
    <dc:creator>Aviral-Bhardwaj</dc:creator>
    <dc:date>2022-12-20T14:06:47Z</dc:date>
    <item>
      <title>Access same createorreplacetempview("viewname") by multiple functions.</title>
      <link>https://community.databricks.com/t5/data-engineering/access-same-createorreplacetempview-quot-viewname-quot-by/m-p/15958#M10208</link>
      <description>&lt;P&gt;I have several functions accessing the same createorreplacetempview("viewname"). Does this cause any issues with multiple functions accessing it in a distributed environment?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def get_data_sql(spark_session, data_frame, data_element):
        data_frame.createOrReplaceTempView("data")
        return spark_session.sql(
        f"""
        SELECT id, {data_element} FROM  data
        """
        )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then I have these two functions calling the above function like this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def get_key(spark_session, data_frame):
        return  get_data_sql(
               spark_session,data_frame,key
        )&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;def get_value(spark_session, data_frame):
        return  get_data_sql(
               spark_session,data_frame,value
        )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Should I be creating the temporary view in each of the calling functions with a separate name to avoid contention/clash?&lt;/P&gt;&lt;P&gt;My understanding is the once the view is created it lasts for the whole session and there would be no issues with multiple access in a distributed environment.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 13:49:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/access-same-createorreplacetempview-quot-viewname-quot-by/m-p/15958#M10208</guid>
      <dc:creator>vk217</dc:creator>
      <dc:date>2022-12-19T13:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Access same createorreplacetempview("viewname") by multiple functions.</title>
      <link>https://community.databricks.com/t5/data-engineering/access-same-createorreplacetempview-quot-viewname-quot-by/m-p/15959#M10209</link>
      <description>&lt;P&gt;there is two type of views&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one is global view - it will be available for whole cluster and notebook but it will removed after cluster restart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and another is Temp view- that will be available for only notebook level, and other notebook will not able to see that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you will get little bit idea on this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Aviral Bhardwaj&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 14:06:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/access-same-createorreplacetempview-quot-viewname-quot-by/m-p/15959#M10209</guid>
      <dc:creator>Aviral-Bhardwaj</dc:creator>
      <dc:date>2022-12-20T14:06:47Z</dc:date>
    </item>
  </channel>
</rss>

