" INSERT INTO ..​​."与SparkSQL HiveContext [英] "INSERT INTO ..." with SparkSQL HiveContext

查看:734
本文介绍了" INSERT INTO ..​​."与SparkSQL HiveContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的HiveContext运行一个INSERT语句,像这样的:

I'm trying to run an insert statement with my HiveContext, like this:

hiveContext.sql('insert into my_table (id, score) values (1, 10)')

借助 1.5.2星火SQL文档不明确指出这是否是支持或不,尽管它的确支持动态分区插入。

The 1.5.2 Spark SQL Documentation doesn't explicitly state whether this is supported or not, although it does support "dynamic partition insertion".

这导致堆栈跟踪像

AnalysisException: 
Unsupported language features in query: insert into my_table (id, score) values (1, 10)
TOK_QUERY 0, 0,20, 0
  TOK_FROM 0, -1,20, 0
    TOK_VIRTUAL_TABLE 0, -1,20, 0
      TOK_VIRTUAL_TABREF 0, -1,-1, 0
        TOK_ANONYMOUS 0, -1,-1, 0
      TOK_VALUES_TABLE 1, 13,20, 41
        TOK_VALUE_ROW 1, 15,20, 41
          1 1, 16,16, 41
          10 1, 19,19, 44
  TOK_INSERT 1, 0,-1, 12
    TOK_INSERT_INTO 1, 0,11, 12
      TOK_TAB 1, 4,4, 12
        TOK_TABNAME 1, 4,4, 12
          my_table 1, 4,4, 12
      TOK_TABCOLNAME 1, 7,10, 22
        id 1, 7,7, 22
        score 1, 10,10, 26
    TOK_SELECT 0, -1,-1, 0
      TOK_SELEXPR 0, -1,-1, 0
        TOK_ALLCOLREF 0, -1,-1, 0

scala.NotImplementedError: No parse rules for:
 TOK_VIRTUAL_TABLE 0, -1,20, 0
  TOK_VIRTUAL_TABREF 0, -1,-1, 0
    TOK_ANONYMOUS 0, -1,-1, 0
  TOK_VALUES_TABLE 1, 13,20, 41
    TOK_VALUE_ROW 1, 15,20, 41
      1 1, 16,16, 41
      10 1, 19,19, 44

是否有任何其他方式插入到蜂房表的支持?

推荐答案

我有同样的问题(星火1.5.1),并尝试不同的版本。

I've had the same problem (Spark 1.5.1), and tried different versions.

由于

sqlContext.sql("create table my_table(id int, score int)")

这是工作的唯一的版本是这样的:

The only versions that worked looked like this:

sqlContext.sql("insert into table my_table select t.* from (select 1, 10) t")
sqlContext.sql("insert into       my_table select t.* from (select 2, 20) t")

这篇关于" INSERT INTO ..​​."与SparkSQL HiveContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆