Saving Hive query results in a table

How do you save the Hive query results in a table?

I am not sure whether i have understood your question correctly. Is it something like you need to store the Hive output into a table ?

If yes, May be, you can refer Lecture 58 : Sqoop Export - Update and Upsert in Durga Sir video(Using Pyspark).


Create table in mysql:

create table daily_revenue(order_date varchar(30) primary key, revenue float);

Moving from Hive into SQL table

sqoop export
–connect jdbc:mysql://quickstart.cloudera:3306/retail_db
–username retail_dba
–password cloudera
–export-dir /user/hive/warehouse/mvmanikan_sqoop_import.db/daily_revenue
–table daily_revenue
–input-fields-terminated-by “\001”
–num-mappers 1

No, that 's not what I am asking. What I meant was that let’s say you write a query in HIVE and do all the data manipulation and you want to send the results of the query to HDFS directly. Do you always have to create a table first using ‘select as’ option or is there a direct way you can send the results of the query to HDFS. In such case (when you manipulate the data in query), is view a better option?

For example, I made data manipulation in hotel_review table and results are shown below,


Then i would like to store the query result from Hive into a HDFS as shown below,


Then i would see the results as shown below,


Yes, that’s what I was asking. Thanks for the help!