How we can run spark SQL over hive tables in our cluster

–1 vote
Dec 26, 2018 in Big Data Hadoop by digger
• 26,740 points
1,585 views

1 answer to this question.

0 votes

Open spark-shell.

scala> import org.apache.spark.sql.hive._
scala> val hc = new HiveContext(sc)
hc.sql("your query").show()
answered Dec 26, 2018 by Omkar
• 69,220 points

Open Spark-shell

scala>val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)
scala>sqlContext.sql("CREATE TABLE IF NOT EXISTS employee(id INT, name STRING, age INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'")
scala>sqlContext.sql("LOAD DATA LOCAL INPATH 'employee.txt' INTO TABLE employee")
scala>val result = sqlContext.sql("FROM employee SELECT id, name, age")
scala>result.show()

Related Questions In Big Data Hadoop

0 votes
1 answer

How can we access data with simple SQL knowledge in hive?

Hey, The following examples are simple, common data ...READ MORE

answered May 16, 2019 in Big Data Hadoop by Gitika
• 65,770 points
653 views
0 votes
1 answer

How can we configure remote metastore mode in Hive?

Hey,  Basically, hive-site.xml file has to be configured ...READ MORE

answered Jun 19, 2019 in Big Data Hadoop by Gitika
• 65,770 points
1,461 views
0 votes
1 answer

How can we use IN/EXIST operator in Hive?

Hey, Yes, now Hive supports IN or EXIST, ...READ MORE

answered Jun 19, 2019 in Big Data Hadoop by Gitika
• 65,770 points
8,731 views
0 votes
1 answer

Update hdfs data before stroring in MySql

Yes, you can update the data before ...READ MORE

answered Jan 27, 2019 in Big Data Hadoop by Omkar
• 69,220 points
787 views
0 votes
1 answer

SOURCE $HIVE_HOME/scripts/metastore/upgrade/mysql/hive-schema-0.14.0.mysql.sql; ERROR:

Hi@akhtar, I think mysql is not able to ...READ MORE

answered Feb 13, 2020 in Big Data Hadoop by MD
• 95,460 points
1,604 views
0 votes
1 answer

Using Hadoop for Data Analytics.

Yes, your approach is correct - you ...READ MORE

answered Sep 28, 2018 in Big Data Hadoop by Frankie
• 9,830 points
762 views
0 votes
1 answer

How to open MySql console in Ubuntu?

sudo service mysqld restart mysql -u <username> root ...READ MORE

answered Dec 14, 2018 in Big Data Hadoop by Omkar
• 69,220 points
2,581 views
0 votes
1 answer

How to save Spark dataframe as dynamic partitioned table in Hive?

Hey, you can try something like this: df.write.partitionBy('year', ...READ MORE

answered Nov 6, 2018 in Big Data Hadoop by Omkar
• 69,220 points
8,548 views
0 votes
1 answer

If there are two joins in hive, how many mapreduce jobs will run?

There are two conditions for no. of ...READ MORE

answered Dec 19, 2018 in Big Data Hadoop by Omkar
• 69,220 points
6,935 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP