Sam Tunnicliffe created HIVE-6337:
-------------------------------------
Summary: Allow non-primitive types to be converted to other types
Key: HIVE-6337
URL: https://issues.apache.org/jira/browse/HIVE-6337
Project: Hive
Issue Type: Improvement
Reporter: Sam Tunnicliffe
The use case I have in mind is to write a UDF which allows collections of one
type to be converted to collections of another type. For instance, I'd like to
be able to define a UDF (string_to_int) to do:
{code}
INSERT INTO TABLE int_table SELECT cast(id_string as int),
string_to_int(strings) FROM string_table;
{code}
where the tables are defined like so:
{code}
hive> DESCRIBE string_table;
OK
id_string string None
strings array<string> None
hive> DESCRIBE int_table;
OK
id_int int None
ints array<int> None
{code}
Right now, this fails at the analysis stage with:
{code}
2014-01-30 12:01:13,300 ERROR ql.Driver (SessionState.java:printError(419)) -
FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into target
table because column number/types are different 'int_table': Cannot convert
column 1 from array<string> to array<int>.
org.apache.hadoop.hive.ql.parse.SemanticException: Line 1:18 Cannot insert into
target table because column number/types are different 'int_table': Cannot
convert column 1 from array<string> to array<int>.
at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genConversionSelectOperator(SemanticAnalyzer.java:5403)
at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genFileSinkPlan(SemanticAnalyzer.java:5240)
at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPostGroupByBodyPlan(SemanticAnalyzer.java:7428)
at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genBodyPlan(SemanticAnalyzer.java:7320)
at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genPlan(SemanticAnalyzer.java:8123)
at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:8349)
at
org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:284)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:441)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:342)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:977)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:888)
at
org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:259)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:216)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413)
at
org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:781)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
{code}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)