我们可以使用Spark-SQL更新Hive表中的行吗?

时间:2016-07-01 06:18:44

标签: apache-spark apache-spark-sql spark-dataframe

试过这样:

HiveContext  hiveql=new org.apache.spark.sql.hive.HiveContext(ctx);
hiveql.sql("UPDATE sparkexamples.employee SET empname='Sreeharsha' WHERE empid='1210'");

提交作业:

./bin/spark-submit 
    --class com.spark.examples.SparkUpdateHiveContext 
    --master local[4] /home/hadoop/SparkHIveUpdate.jar

获取以下错误:请提出任何建议

16/07/01 11:45:38 INFO parse.ParseDriver: Parse Completed
Exception in thread "main" org.apache.spark.sql.AnalysisException: 
Unsupported language features in query: 
UPDATE sparkexamples.employee SET empname='Sreeharsha' WHERE empid='1210'
TOK_UPDATE_TABLE 1, 0,16, 7
 TOK_TABNAME 1, 2,4, 7
   sparkexamples 1, 2,2, 7
   employee 1, 4,4, 21
 TOK_SET_COLUMNS_CLAUSE 1, 6,10, 41
   = 1, 8,10, 41
     TOK_TABLE_OR_COL 1, 8,8, 34
       empname 1, 8,8, 34
     'Sreeharsha' 1, 10,10, 42
 TOK_WHERE 1, 12,16, 66
   = 1, 14,16, 66
     TOK_TABLE_OR_COL 1, 14,14, 61
       empid 1, 14,14, 61
     '1210' 1, 16,16, 67
scala.NotImplementedError: No parse rules for TOK_UPDATE_TABLE:
TOK_UPDATE_TABLE 1, 0,16, 7
 TOK_TABNAME 1, 2,4, 7
   sparkexamples 1, 2,2, 7
   employee 1, 4,4, 21
 TOK_SET_COLUMNS_CLAUSE 1, 6,10, 41
   = 1, 8,10, 41
     TOK_TABLE_OR_COL 1, 8,8, 34
       empname 1, 8,8, 34
     'Sreeharsha' 1, 10,10, 42
 TOK_WHERE 1, 12,16, 66
   = 1, 14,16, 66
     TOK_TABLE_OR_COL 1, 14,14, 61
       empid 1, 14,14, 61
     '1210' 1, 16,16, 67
org.apache.spark.sql.hive.HiveQl$.nodeToPlan(HiveQl.scala:1086)

0 个答案:

没有答案