Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

issue while inserting data into hive through spark

avatar
Rising Star

Not able to insert data into hive table through spark

scala> sqlContext.sql("insert into table results_test_hive values('XXXXXXXXXX', 'm:X', 0.0)")

Failed with below error,

org.apache.spark.sql.AnalysisException:

Unsupported language features in query: insert into table results_test_hive values('XXXXXXXXXX', 'm:X', 0.0)

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Hi @prsingh, Spark currently doesn't support "insert into feature", you may create dataframe and append to the table.

scala> var data = sqlContext.createDataFrame(Seq(("ZZ", "m:x", 34.0))).toDF("pv", "metric", "value") 
scala> data.show() 
scala> data.write.mode("append").saveAsTable("results_test_hive") 
scala> println(sqlContext.sql("select * from results_test_hive").count())

View solution in original post

2 REPLIES 2

avatar
Expert Contributor

Hi @prsingh, Spark currently doesn't support "insert into feature", you may create dataframe and append to the table.

scala> var data = sqlContext.createDataFrame(Seq(("ZZ", "m:x", 34.0))).toDF("pv", "metric", "value") 
scala> data.show() 
scala> data.write.mode("append").saveAsTable("results_test_hive") 
scala> println(sqlContext.sql("select * from results_test_hive").count())

avatar
Rising Star

@nyadav

Thanks for the information . I was able to insert after creating the dataframe.