title: Datastax Spark-Cassandra | getting NPE
body: <p>Spark Jar Version: 2.10-1.4.2.5</p>
  
  <p>I have the following code which does some basic query on spark-cassandra cluster (dse cassandra using spark). The following query works most of the time, but sometimes code throws below exception. </p>
  
  <p><strong><em>Table Structure</em></strong></p>
  
  <pre><code>id | appname | appinstname | snapdate | evnthour | actor | avg_c001_1w | avg_c001_4w | avg_c001_8w | avg_c002_1w | avg_c002_4w | avg_c002_8w | avg_c003_1w | avg_c003_4w | avg_c003_8w | avg_c004_1w | avg_c004_4w | avg_c004_8w | avg_c005_1w.......avg_c075
  </code></pre>
  
  <p><strong><em>Query executed using hivecontext</em></strong></p>
  
  <pre><code>select * from (    
         select *,    row_number() over (order by evnthour desc) rn    
         from testing 
         where  id= '9fcb1' and appname='ABC' and appinstname='dc8cc' and snapdate='2017-12-22' and actor='xyz@gmai.comv 
       ) t1 where rn = 1
  </code></pre>
  
  <p><strong>Error Trace</strong></p>
  
  <pre><code>... 41 common frames omitted
  at org.apache.spark.sql.catalyst.errors.package$.attachTree(package.scala:48) ~[spark-catalyst_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.Exchange$$anonfun$doExecute$1.apply(Exchange.scala:172) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.Exchange$$anonfun$doExecute$1.apply(Exchange.scala:236) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.Exchange.org$apache$spark$sql$execution$Exchange$$needToCopyObjectsBeforeShuffle(Exchange.scala:89) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  
  Caused by: java.lang.NullPointerException: null
  ... 33 common frames omitted
  at org.apache.spark.sql.catalyst.errors.package$.attachTree(package.scala:48) ~[spark-catalyst_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.Sort$$anonfun$doExecute$5.apply(basicOperators.scala:212) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.Sort$$anonfun$doExecute$5.apply(basicOperators.scala:212) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:87) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:147) ~[spark-core_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:88) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:88) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.execution.Exchange.doExecute(Exchange.scala:171) ~[spark-sql_2.10-1.4.2.5.jar:1.4.2.5]
  at org.apache.spark.sql.catalyst.errors.package$.attachTree(package.scala:49) ~[spark-catalyst_2.10-1.4.2.5.jar:1.4.2.5]
  </code></pre>
  
  <p>I am unable to find out the actual cause of this failure through log trace. Any suggestions?</p>