“INSERT INTO …” with SparkSQL HiveContext

前端 未结 6 1401
你的背包
你的背包 2021-02-05 05:32

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

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

Th

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 05:49

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

    Given

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

提交回复
热议问题