<?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>question Re: How to get the non group by columns in spark structured streaming in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-get-the-non-group-by-columns-in-spark-structured/m-p/200514#M162535</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/24259/elangork.html" nodeid="24259"&gt;@elango vaithiyanathan&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;To get &lt;STRONG&gt;non group by columns&lt;/STRONG&gt; after &lt;STRONG&gt;grouped dataframe&lt;/STRONG&gt;, we need to use one of the &lt;STRONG&gt;aggregate(agg)&lt;/STRONG&gt; function(&lt;STRONG&gt;max, min, mean and sum..etc) &lt;/STRONG&gt;for all the non group by columns.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example:-&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;val grpbyDF = updatedDf.groupBy("ROW_ID","ODS_WII_VERB").agg(&amp;lt;strong&amp;gt;max&amp;lt;/strong&amp;gt;("STG_LOAD_TS"),&amp;lt;strong&amp;gt;min&amp;lt;/strong&amp;gt;("non groupby column"),&amp;lt;strong&amp;gt;mean&amp;lt;/strong&amp;gt;("non groupby column"),&amp;lt;strong&amp;gt;sum&amp;lt;/strong&amp;gt;("non groupby column"))&lt;/PRE&gt;&lt;P&gt;In the above grpbydf we are grouping by &lt;STRONG&gt;ROW_ID,ODS_WII_VERB an&lt;/STRONG&gt;d all non group by columns are in agg function with one of the function(max, min, mean and sum).&lt;/P&gt;&lt;P&gt;Please Refer to below link for more details about groupBy&lt;BR /&gt;&lt;A href="http://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.DataFrame.groupBy" target="_blank"&gt;http://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.DataFrame.groupBy&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Feb 2018 13:59:43 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2018-02-04T13:59:43Z</dc:date>
  </channel>
</rss>

