Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

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

Explorer

 

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

2 REPLIES 2

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

Explorer

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.

Highlighted

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

Expert Contributor

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.

Don't have an account?
Coming from Hortonworks? Activate your account here