Reply
Highlighted
Explorer
Posts: 13
Registered: ‎02-29-2016

Read from Hive table and write as text file in a server

 

Hi ,

 

Trying to read a hive table and write as text delimited file selecting few columns. Is it possible to write the text file into a server from Spark-shell as could see possible only in Hadoop files. Please help out the syntax for this if it is possible.

 

Thanks

Explorer
Posts: 13
Registered: ‎02-29-2016

Re: Read from Hive table and write as text file in a server

Write into HDFS files is done using rdd.saveAsTextFile commands. But right from table read , is it possible to write into some server directly as text file  and not into HDFS path.

Expert Contributor
Posts: 133
Registered: ‎01-08-2018

Re: Read from Hive table and write as text file in a server

You can use beeline:

beeline -n username -p password -u jdbc:hive2://hiveserver:10000 -e "select a,b,c from table1"  --outputformat=csv2 --silent=true > output_file.csv

You can add "--showHeader=true" if you want headers to be included.

Announcements