Hive将值插入数组复杂类型列 [英] Hive inserting values to an array complex type column

查看:4744
本文介绍了Hive将值插入数组复杂类型列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用insert into语句将数据追加到包含数组列的表中;数据类型是数组< varchar(200)>



使用jodbc我无法通过如下值将值插入数组列:

  INSERT INTO demo.table(codes)VALUES(['a','b']); 

不会识别[或{符号。



$ p $ INSERT INTO demo.table(code)VALUES(array)

使用数组函数,如...

  INSERT INTO demo.table ( 'A', 'b')); 

我使用数组函数得到以下错误:

 无法为插入值创建临时文件在插入/值中不支持表达式TOK_FUNCTION 

尝试了解决方法......

  INSERT into demo.table(codes)select array 'A', 'b'); 

失败:

 无法识别谓词'< EOF>'。失败的规则:声明中的'regularBody'

如何使用jdbc将数组数据加载到列中? p>

解决方案

我的表格有两列: a STRING,b ARRAY< STRING>

当我使用@Kishore Kumar Suthar的方法时,我得到了这个:

FAILED :ParseException行1:33无法识别'('''','在语句



'附近的输入但我找到另一个它适用于我:

 插入test.table 
SELECTtest1, ARRAY(123,456,789)
从假限制1;

dummy 是任何至少有一行的表。


I am unable to append data to tables that contain an array column using insert into statements; the data type is array < varchar(200) >

Using jodbc I am unable to insert values into an array column by values like :

INSERT INTO demo.table (codes) VALUES (['a','b']);

does not recognises the "[" or "{" signs.

Using the array function like ...

INSERT INTO demo.table (codes) VALUES (array('a','b'));

I get the following error using array function:

Unable to create temp file for insert values Expression of type TOK_FUNCTION not supported in insert/values

Tried the workaround...

INSERT into demo.table (codes) select array('a','b');

unsuccessfully:

Failed to recognize predicate '<EOF>'. Failed rule: 'regularBody' in statement

How can I load array data into columns using jdbc ?

解决方案

My Table has two columns: a STRING, b ARRAY<STRING>.

When I use @Kishore Kumar Suthar's method, I got this:

FAILED: ParseException line 1:33 cannot recognize input near '(' 'a' ',' in statement

But I find another way, and it works for me:

INSERT INTO test.table 
SELECT "test1", ARRAY("123", "456", "789") 
FROM dummy LIMIT 1;

dummy is any table which has atleast one row.

这篇关于Hive将值插入数组复杂类型列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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