title: Spark error: Unsupported literal type class sql.catalyst.expressions.GenericRowWithSchema
body: <blockquote>
    <p>Spark error: Unsupported literal type class sql.catalyst.expressions.GenericRowWithSchema</p>
  </blockquote>
  
  <pre><code>val crimeDF = spark.read.option("header", "true").csv("crime_data.csv")
  crimeDF.show(5)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xLt2w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xLt2w.png" alt="enter image description here"></a></p>
  
  <pre><code>var a = crimeDF.select(max($"IncidntNum")).take(1)
  println(a(0).toString)
  
   a: Array[org.apache.spark.sql.Row] = Array([991309046])
      [991309046]
  </code></pre>
  
  <p>I am executing this command:</p>
  
  <pre><code>crimeDF.where($"IncidntNum ===" +a(0))
  </code></pre>
  
  <p>but getting this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>java.lang.RuntimeException: Unsupported literal type class org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema [991309046]
    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 org.apache.spark.sql.Column.$plus(Column.scala:648)
    ... 76 elided
  </code></pre>