I have the below requirement that i want to achieve using Hive.
- Table A with Struct 1 column.
- Create Table B to split Table A's Struct columns and load as 2 different columns.
Below is the DDL and the steps that i have tried.
Table A :
cluster string from deserializer
schema string from deserializer
table string from deserializer
primarykey struct from deserializer
data struct from deserializer
deleted boolean from deserializer
truncate boolean from deserializer
version bigint from deserializer
Table B :
user_id string from deserializer
shippingattr struct
billingattr struct
i have tried the following.
insert into Table B
(
user_id,
shippingattr.username,
shippingattr.shipping_fname,
shippingattr.shipping_lname,
shippingattr.shipping_address,
shippingattr.shipping_address2,
shippingattr.shipping_city,
shippingattr.shipping_state,
shippingattr.shipping_zip,
shippingattr.phone,
billingattr.billing_is_shipping,
billingattr.billing_fname,
billingattr.billing_lname,
billingattr.billing_address,
billingattr.billing_address2,
billingattr.billing_city,
billingattr.billing_state,
billingattr.billing_zip
)
select
primarykey.user_id,
data.username,
data.shipping_fname,
data.shipping_lname,
data.shipping_address,
data.shipping_address2,
data.shipping_city,
data.shipping_state,
data.shipping_zip,
data.phone,
data.billing_is_shipping,
data.billing_fname,
data.billing_lname,
data.billing_address,
data.billing_address2,
data.billing_city,
data.billing_state,
data.billing_zip
from Table A;
but this errors out., could you please let me know the right way to insert this data.
Error Message : NoViableAltException(284@[]) at org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectClause(HiveParser_SelectClauseParser.java:742) at org.apache.hadoop.hive.ql.parse.HiveParser.selectClause(HiveParser.java:40147) at org.apache.hadoop.hive.ql.parse.HiveParser.singleSelectStatement(HiveParser.java:38048) at org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:37754) at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:37654) at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:36898) at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:36774) at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1338) at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1036) at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199) at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:404) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:322) at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:975) at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1040) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:911) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:901) at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:275) at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:227) at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:430) at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:803) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:697) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:636) 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:212) FAILED: ParseException line 1:50 cannot recognize input near '(' 'user_id' ',' in select clause