请问哪位有没有用spark 读取hbase 或者hive 进行sql 操作的代码示例

0
已邀请:
0

regan - run! run! run! happy runner! 我是奔跑的小米~ 2017-02-20 回答

beeline -u "jdbc:hive2://172.16.18.87:10001/default;transportMode=http;httpPath=cliservice" -n spark -e"create \
table insurance_dm.accident_analysis_beeline as select imei,longitude,latitude,data_date,time from dsp_dw.cw_location_trace_new \
where data_date >= 20161210 and longitude > 119.710 and longitude <119.719 and latitude > 37.000 \
and latitude <37.009;"
 
直接写脚本读就是了。如果要在Spark里面读取Hive表,需要在spark中启用hive支持,然后在Spark的conf目录中加入hive的hive-site.xml文件,就能直接使用sql("select * from hivetable")操作了。当然要读取hbase中的数据,建议使用hbase-rdd这样一个开源的插件

要回复问题请先登录注册