无法在spark sql中查看配置单元记录,但可以在配置单元cli上查看它们

gudnpqoy  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(285)

我无法在spark sql中查看配置单元记录,但可以在配置单元cli上查看它们。
当配置单元cli显示2条记录时,使用配置单元上下文的同一查询显示0
在Hive里

hive> select ord_id from order;
OK
157434411
157435932
Time taken: 0.389 seconds, Fetched: 2 row(s)

在spark sql中

hiveCtx.sql("select ord_id from order").show()
   +------------+
   |ord_id      |
   +------------+
   +------------+

我已尝试刷新表,并重新启动配置单元,但问题仍然存在。
我在spark中检查了更新后无法查看配置单元表数据的解决方案,但似乎什么都不起作用。
如有任何建议,我们将不胜感激。
编辑:
更正了上面列的名称。我还提供了desc的输出:

hive> desc rpt_derived.rpttradeleg;
OK                                  
ord_id              string                                      
ord_date            timestamp                                                                   
cust_buy_sell       string                                      
ord_cust_entity     string                                                              
ord_deal_year           int                                         
ord_deal_month          int                                         
ord_deal_day            int                                         

# Partition Information

# col_name              data_type               comment

ord_year        int                                         
ord_month       int                                         
ord_day         int                                         
Time taken: 2.036 seconds, Fetched: 16 row(s)
hive>

来自spark sql:

scala> hiveContext.sql("desc rpt_derived.rpttradeleg").show()
+--------------------+---------+-------+
|            col_name|data_type|comment|
+--------------------+---------+-------+
|              ord_id|   string|       |
|            ord_date|timestamp|       |
|       cust_buy_sell|   string|       |
|     ord_cust_entity|   string|       |
|       ord_deal_year|      int|       |
|      ord_deal_month|      int|       |
|        ord_deal_day|      int|       |
+--------------------+---------+-------+

spark版本:spark-1.5.0+cdh5.5.2+114
配置单元版本:hive-1.1.0+cdh5.5.2+377

wlwcrazw

wlwcrazw1#

To connect to hive metastore you need to copy the hive-site.xml file into 
spark/conf directory.After that spark will be able to connect to hive 
metastore.
so run the  following command after log in as root user   

cp  /usr/lib/hive/conf/hive-site.xml    /usr/lib/spark/conf/

or use hiveCtx.sql("select *from databasename.tablename").show()

I hope, it will work for you.

相关问题