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.

I am trying to insert into HIVE table through spark-sql and it fails.. Any help ?

avatar
Contributor

Below is the query I am using.

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
@rakanchi

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

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

View solution in original post

1 REPLY 1

avatar
Expert Contributor
@rakanchi

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

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