<?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 Unsupported literal type class in Apache Spark in scala in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Unsupported-literal-type-class-in-Apache-Spark-in-scala/m-p/227033#M188893</link>
    <description>&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;I'm trying to add a column to a dataframe based on multiple check condition, one of the operation that we are doing is we need to take sum of rows, but im getting Below error: &lt;/P&gt;&lt;P&gt;Exception in thread "main" java.lang.RuntimeException: Unsupported literal type class org.apache.spark.sql.Dataset [StorageDayCountBeore: double]
at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:77)
at org.apache.spark.sql.catalyst.expressions.Literal$anonfun$create$2.apply(literals.scala:163)
at org.apache.spark.sql.catalyst.expressions.Literal$anonfun$create$2.apply(literals.scala:163)
at scala.util.Try.getOrElse(Try.scala:79)
at org.apache.spark.sql.catalyst.expressions.Literal$.create(literals.scala:162)
at org.apache.spark.sql.functions$.typedLit(functions.scala:112)
at org.apache.spark.sql.functions$.lit(functions.scala:95)
at MYDev.ReconTest$.main(ReconTest.scala:35)
at MYDev.ReconTest.main(ReconTest.scala)&lt;/P&gt;&lt;P&gt;
and the Query im using is:&lt;/P&gt;&lt;PRE&gt;var df = inputDf&lt;BR /&gt;df = df.persist()&lt;BR /&gt;inputDf = inputDf.withColumn("newColumn",&lt;BR /&gt;  when(df("MinBusinessDate") &amp;lt; "2018-08-8" &amp;amp;&amp;amp; df("MaxBusinessDate") &amp;gt; "2018-08-08",&lt;BR /&gt;    lit(df.groupBy(df("tableName"),df("runDate"))&lt;BR /&gt;      .agg(sum(when(df("business_date") &amp;gt; "2018-08-08", df("rowCount")))&lt;BR /&gt;        .alias("finalSRCcount"))&lt;BR /&gt;      .drop("tableName","runDate"))))&lt;/PRE&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;</description>
    <pubDate>Sun, 26 Aug 2018 21:55:49 GMT</pubDate>
    <dc:creator>manikandanjeyab</dc:creator>
    <dc:date>2018-08-26T21:55:49Z</dc:date>
    <item>
      <title>Unsupported literal type class in Apache Spark in scala</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unsupported-literal-type-class-in-Apache-Spark-in-scala/m-p/227033#M188893</link>
      <description>&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;I'm trying to add a column to a dataframe based on multiple check condition, one of the operation that we are doing is we need to take sum of rows, but im getting Below error: &lt;/P&gt;&lt;P&gt;Exception in thread "main" java.lang.RuntimeException: Unsupported literal type class org.apache.spark.sql.Dataset [StorageDayCountBeore: double]
at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:77)
at org.apache.spark.sql.catalyst.expressions.Literal$anonfun$create$2.apply(literals.scala:163)
at org.apache.spark.sql.catalyst.expressions.Literal$anonfun$create$2.apply(literals.scala:163)
at scala.util.Try.getOrElse(Try.scala:79)
at org.apache.spark.sql.catalyst.expressions.Literal$.create(literals.scala:162)
at org.apache.spark.sql.functions$.typedLit(functions.scala:112)
at org.apache.spark.sql.functions$.lit(functions.scala:95)
at MYDev.ReconTest$.main(ReconTest.scala:35)
at MYDev.ReconTest.main(ReconTest.scala)&lt;/P&gt;&lt;P&gt;
and the Query im using is:&lt;/P&gt;&lt;PRE&gt;var df = inputDf&lt;BR /&gt;df = df.persist()&lt;BR /&gt;inputDf = inputDf.withColumn("newColumn",&lt;BR /&gt;  when(df("MinBusinessDate") &amp;lt; "2018-08-8" &amp;amp;&amp;amp; df("MaxBusinessDate") &amp;gt; "2018-08-08",&lt;BR /&gt;    lit(df.groupBy(df("tableName"),df("runDate"))&lt;BR /&gt;      .agg(sum(when(df("business_date") &amp;gt; "2018-08-08", df("rowCount")))&lt;BR /&gt;        .alias("finalSRCcount"))&lt;BR /&gt;      .drop("tableName","runDate"))))&lt;/PRE&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;</description>
      <pubDate>Sun, 26 Aug 2018 21:55:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unsupported-literal-type-class-in-Apache-Spark-in-scala/m-p/227033#M188893</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2018-08-26T21:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unsupported literal type class in Apache Spark in scala</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unsupported-literal-type-class-in-Apache-Spark-in-scala/m-p/227034#M188894</link>
      <description>&lt;P&gt;Hi Issue got resolved,&lt;/P&gt;&lt;P&gt;i'm trying to perform Group by operation inside a Columns literal, group by itself will produce a new columns instead writing a query like i asked above we have to change our query accordingly as follow.&lt;/P&gt;&lt;PRE&gt;inputDf = inputDf.groupBy(col("tableName"),col("runDate"))&lt;BR /&gt;  .agg(sum(when(col("MinBusinessDate") &amp;lt; col("runDate") &amp;amp;&amp;amp; col("MaxBusinessDate") &amp;gt; col("runDate"),&lt;BR /&gt;    when(col("business_date") &amp;gt; col("runDate"), col("rowCount")))).alias("NewColumnName"))&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Aug 2018 22:18:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unsupported-literal-type-class-in-Apache-Spark-in-scala/m-p/227034#M188894</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2018-08-27T22:18:20Z</dc:date>
    </item>
  </channel>
</rss>

