<?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 Quering hive table from spark-shell in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Quering-hive-table-from-spark-shell/m-p/293776#M216869</link>
    <description>&lt;P&gt;I tried to run a select query on a hive table through spark shell. this is my code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;scala &amp;gt;import org.apache.spark.sql.hive.HiveContext                                                                                                                     
scala &amp;gt;val sqlContext = new HiveContext(sc)    
scala &amp;gt;val df = sqlContext.sql("select count(*) from bdp.serie")
scala &amp;gt;df.head  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but I got an error when I execute any read command (&lt;/SPAN&gt;df.head&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;df.count&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;df.show&lt;SPAN&gt;) . this is the error :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;org.apache.spark.sql.catalyst.errors.package$TreeNodeException: execute, tree:                                                                                          
Exchange SinglePartition                                                                                                                                                
+- *(1) HashAggregate(keys=[], functions=[partial_count(1)], output=[count#13L])                                                                                        
+- HiveTableScan HiveTableRelation `bdp`.`serie`, 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [data#0, temperature#1, hum#2]                         

at org.apache.spark.sql.catalyst.errors.package$.attachTree(package.scala:56)                                                                                         
at org.apache.spark.sql.execution.exchange.ShuffleExchangeExec.doExecute(ShuffleExchangeExec.scala:119)                                                               
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131)                                                                                                                                                                                                                                                                                  
... 49 elided                                                                                                                                                         
Caused by: java.io.IOException: Not a file: hdfs://sandbox- 
hdp.hortonworks.com:8020/warehouse/tablespace/managed/hive/bdp.db/serie/delta_0000001_0000001_0000              
at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:337)                                                                                       
at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:200)                                                                                                  
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:253)                                                                                                
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:251)                                                                                                                                                                                                                                                                                     
... 73 more  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;ps : when I execute the&amp;nbsp;&lt;/SPAN&gt;show tables&lt;SPAN&gt;&amp;nbsp;query I get the result without error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;show create table serie :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stack1.PNG" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/27097i57A7B60CEE2BB979/image-size/medium?v=v2&amp;amp;px=400" role="button" title="stack1.PNG" alt="stack1.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and hdfs dfs -ls ../../warehouse/tablespace/managed/hive/bdp.db/serie&amp;nbsp; :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stck2.PNG" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/27098i4B6F0995648B6EA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="stck2.PNG" alt="stck2.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Apr 2020 10:24:33 GMT</pubDate>
    <dc:creator>hicha</dc:creator>
    <dc:date>2020-04-12T10:24:33Z</dc:date>
  </channel>
</rss>

