Monday, September 11, 2017

Spark and Hive integration

Spark Sql and Hql

[cloudera@quickstart ~]$ sudo find / -name 

'hive-site.xml'

[cloudera@quickstart ~]$ sudo chmod -R 777 

/usr/lib/spark/conf
[cloudera@quickstart ~]$ cp 

/etc/hive/conf.dist/hive-site.xml 

/usr/lib/spark/conf
_____________________________________
from hive-site.xml -->  

set hive.metastore.warehouse.dir to some directory path

import org.apache.spark.sql.hive.HiveContext
 val hq = new HiveContext(sc);
    
    val hivedf = hq.sql("use leela_db")
    val hivedf2 = hq.sql("select * from emp_sal")
    hivedf2.show();
    val sal_avg = hq.sql("select avg(salary) from emp_sal")
    sal_avg.show()

4 comments:

  1. Nice post ! Thanks for sharing valuable information with us. Keep sharing.. Big data hadoop online training

    ReplyDelete
  2. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Big Data Hadoop training in electronic city

    ReplyDelete
  3. Your post is very great.I read this post. It’s very helpful. I will definitely go ahead and take advantage of this. You absolutely have wonderful stories. Cheers for sharing with us your blog. For more learning about data science visit at Data science course in Bangalore

    ReplyDelete