<?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 When should I use STREAM() when defining a DLT table? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22293#M15250</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a little confused when I should use STREAM() when we define a table based on a DLT table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a pattern explained in the &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-incremental-data.html?&amp;amp;_ga=2.147178353.716836576.1668475656-221102221.1666669841#language-sql" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-incremental-data.html?&amp;amp;_ga=2.147178353.716836576.1668475656-221102221.1666669841#language-sql" target="_blank"&gt;documentation&lt;/A&gt;.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE OR REFRESH STREAMING LIVE TABLE streaming_bronze
&amp;nbsp;
AS SELECT * FROM cloud_files(
&amp;nbsp;
  "s3://path/to/raw/data", "json"
&amp;nbsp;
)
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
CREATE OR REFRESH STREAMING LIVE TABLE streaming_silver
&amp;nbsp;
AS SELECT * FROM STREAM(LIVE.streaming_bronze) WHERE...
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
CREATE OR REFRESH LIVE TABLE live_gold
&amp;nbsp;
AS SELECT count(*) FROM LIVE.streaming_silver GROUP BY user_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above code, "live_gold" is a live able. Since "streaming_silver" is a streaming live table, I expected the last line of the code to be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AS SELECT count(*) FROM STREAM(LIVE.streaming_silver) GROUP BY user_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, STREAM() is not used in the definition of "live_gold".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering when I should use STREAM() when defining a live table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 11:17:36 GMT</pubDate>
    <dc:creator>Mado</dc:creator>
    <dc:date>2022-11-15T11:17:36Z</dc:date>
    <item>
      <title>When should I use STREAM() when defining a DLT table?</title>
      <link>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22293#M15250</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a little confused when I should use STREAM() when we define a table based on a DLT table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a pattern explained in the &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-incremental-data.html?&amp;amp;_ga=2.147178353.716836576.1668475656-221102221.1666669841#language-sql" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-incremental-data.html?&amp;amp;_ga=2.147178353.716836576.1668475656-221102221.1666669841#language-sql" target="_blank"&gt;documentation&lt;/A&gt;.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE OR REFRESH STREAMING LIVE TABLE streaming_bronze
&amp;nbsp;
AS SELECT * FROM cloud_files(
&amp;nbsp;
  "s3://path/to/raw/data", "json"
&amp;nbsp;
)
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
CREATE OR REFRESH STREAMING LIVE TABLE streaming_silver
&amp;nbsp;
AS SELECT * FROM STREAM(LIVE.streaming_bronze) WHERE...
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
CREATE OR REFRESH LIVE TABLE live_gold
&amp;nbsp;
AS SELECT count(*) FROM LIVE.streaming_silver GROUP BY user_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above code, "live_gold" is a live able. Since "streaming_silver" is a streaming live table, I expected the last line of the code to be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AS SELECT count(*) FROM STREAM(LIVE.streaming_silver) GROUP BY user_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, STREAM() is not used in the definition of "live_gold".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering when I should use STREAM() when defining a live table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 11:17:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22293#M15250</guid>
      <dc:creator>Mado</dc:creator>
      <dc:date>2022-11-15T11:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: When should I use STREAM() when defining a DLT table?</title>
      <link>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22294#M15251</link>
      <description>&lt;P&gt;Hi @Mohammad Saber​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You use STREAM() when creating a STREAMING LIVE TABLE and reading other tables in the pipeline. The key difference is the STREAMING LIVE TABLE vs. LIVE TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The definitions of each tables and when to use them are in the docs &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-concepts.html#datasets" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-concepts.html#datasets" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 20:12:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22294#M15251</guid>
      <dc:creator>LandanG</dc:creator>
      <dc:date>2022-11-15T20:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: When should I use STREAM() when defining a DLT table?</title>
      <link>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22295#M15252</link>
      <description>&lt;P&gt;Thanks @Landan George​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since "streaming_silver" is a streaming live table, I expected the last line of the code to be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AS SELECT count(*) FROM STREAM(LIVE.streaming_silver) GROUP BY user_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But, as you can see the "live_gold" is defined by: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AS SELECT count(*) FROM LIVE.streaming_silver GROUP BY user_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 00:14:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22295#M15252</guid>
      <dc:creator>Mado</dc:creator>
      <dc:date>2022-11-16T00:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: When should I use STREAM() when defining a DLT table?</title>
      <link>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22296#M15253</link>
      <description>&lt;P&gt;@Mohammad Saber​&amp;nbsp;I think I see what you're saying. You only need to include the STREAM() function when declaring a STREAMING LIVE TABLE, it doesn't matter the source of data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So since the live_gold table is just a LIVE TABLE and not a STREAMING LIVE TABLE you do not need to include that function. Hopefully, that makes sense&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 00:51:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/when-should-i-use-stream-when-defining-a-dlt-table/m-p/22296#M15253</guid>
      <dc:creator>LandanG</dc:creator>
      <dc:date>2022-11-16T00:51:30Z</dc:date>
    </item>
  </channel>
</rss>

