<?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 how to compute difference over time of a spark structure streaming? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11328#M6318</link>
    <description>&lt;P&gt;I have a table with a timestamp column (t) and a list of columns for which I would like to compute the difference over time (v), by some key(k): v_diff(t) = v(t)-v(t-1) for each k independently.&lt;/P&gt;&lt;P&gt;Normally I would write:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lag_window = Window.partitionBy(COLS_TO_DIFF).orderBy('timestamp')
&amp;nbsp;
for col in COLS_TO_DIFF:
  df = df.withColumn(
    col + "_diff",
    df[col] - F.lag(df[col]).over(lag_window))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AnalysisException: Non-time-based windows are not supported on streaming DataFrames/Datasets;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, my question is how do I compute what I need?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jan 2023 15:48:14 GMT</pubDate>
    <dc:creator>chanansh</dc:creator>
    <dc:date>2023-01-18T15:48:14Z</dc:date>
    <item>
      <title>how to compute difference over time of a spark structure streaming?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11328#M6318</link>
      <description>&lt;P&gt;I have a table with a timestamp column (t) and a list of columns for which I would like to compute the difference over time (v), by some key(k): v_diff(t) = v(t)-v(t-1) for each k independently.&lt;/P&gt;&lt;P&gt;Normally I would write:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lag_window = Window.partitionBy(COLS_TO_DIFF).orderBy('timestamp')
&amp;nbsp;
for col in COLS_TO_DIFF:
  df = df.withColumn(
    col + "_diff",
    df[col] - F.lag(df[col]).over(lag_window))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AnalysisException: Non-time-based windows are not supported on streaming DataFrames/Datasets;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, my question is how do I compute what I need?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 15:48:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11328#M6318</guid>
      <dc:creator>chanansh</dc:creator>
      <dc:date>2023-01-18T15:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to compute difference over time of a spark structure streaming?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11329#M6319</link>
      <description>&lt;P&gt;I asked it also in Stack-overflow since I don't get an answer here &lt;A href="https://stackoverflow.com/questions/75161849/spark-structure-streaming-differentiate-over-time" target="test_blank"&gt;https://stackoverflow.com/questions/75161849/spark-structure-streaming-differentiate-over-time&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2023 11:54:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11329#M6319</guid>
      <dc:creator>chanansh</dc:creator>
      <dc:date>2023-01-22T11:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to compute difference over time of a spark structure streaming?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11330#M6320</link>
      <description>&lt;P&gt;I found this but could not make it work &lt;A href="https://www.databricks.com/blog/2022/10/18/python-arbitrary-stateful-processing-structured-streaming.html" target="test_blank"&gt;https://www.databricks.com/blog/2022/10/18/python-arbitrary-stateful-processing-structured-streaming.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 13:32:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-compute-difference-over-time-of-a-spark-structure/m-p/11330#M6320</guid>
      <dc:creator>chanansh</dc:creator>
      <dc:date>2023-02-08T13:32:54Z</dc:date>
    </item>
  </channel>
</rss>

