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.

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

Solved Go to solution
Highlighted

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

Cloudera Employee

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

Accepted Solutions

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

Rising Star
@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

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

Rising Star
@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

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