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.

issue while inserting data into hive through spark

Solved Go to solution

issue while inserting data into hive through spark

Contributor

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

Accepted Solutions

Re: issue while inserting data into hive through spark

Rising Star

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

Re: issue while inserting data into hive through spark

Rising Star

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

Re: issue while inserting data into hive through spark

Contributor

@nyadav

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