Support Questions

Find answers, ask questions, and share your expertise

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())