Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hive creation failed #5

Open
rpushpa opened this issue May 20, 2015 · 9 comments
Open

Hive creation failed #5

rpushpa opened this issue May 20, 2015 · 9 comments

Comments

@rpushpa
Copy link

rpushpa commented May 20, 2015

Hi,
This was so great tool for simplifing the json record into hive structure.
I have created the jar files and used them to generate hive DDL .
But the create table statement is failing in hive.
can you pls help to resolve the issue?

sample data record:
{"country":"uk","state":"ny","city":"fr","street":"nyk","zip":"1009","data":[{"country_code":"uk","state_set":"ny","city_code":"fr","street_code":"nyk","zip_code":"1009"}]}

user@ubuntu:~/lab/programs$ java -jar json-hive-schema-1.0-jar-with-dependencies.jar /home/user/Documents/json_cntry_schema.json
CREATE TABLE x (
city string,
country string,
data array<struct<city_code:string, country_code:string, state_set:string, street_code:string, zip_code:string>>,
state string,
street string,
zip string)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';

hive> CREATE external TABLE jcountry (
> city string,
> country string,
> data array<struct<city_code:string, country_code:string, state_set:string, street_code:string, zip_code:string>>,
> state string,
> street string,
> zip string)
> ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
> LOCATION '/user/data1/jason/';
FAILED: Parse Error: line 4:2 mismatched input 'data' expecting Identifier near ',' in column specification

Thanks ,
Pushpa

@mtoupsUNO
Copy link

This line is wrong:

data array>,

In other words, an array of what?

It looks like your sample is actually an array containing a struct, so maybe something like:

data array<struct<country_code:string, state_set:string, ... >>,

I'll let you finish writing out the struct, but that's the idea.

@rpushpa
Copy link
Author

rpushpa commented May 20, 2015

Thanks.
I have tried same as array having struct data type and given the DDL as shown above.
Still I am failing in creating the table .
More information ::My hive version is hive 0.9 version

@mtoupsUNO
Copy link

Please provide the CREATE statement you used which is not working.

@rpushpa
Copy link
Author

rpushpa commented May 20, 2015

Here is the create table statement i used:
CREATE external TABLE jcountry (
city string,
country string,
data array <struct<city_code:string, country_code:string, state_set:string, street_code:string, zip_code:string>>,
state string,
street string,
zip string)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION '/user/data1/jason/';

@rpushpa
Copy link
Author

rpushpa commented May 21, 2015

Hi..
Just wanted to check if you need any aditional information on resolving the issue

@mtoupsUNO
Copy link

Are you still getting a parse error? If so, what line number? Provide the whole error message here.

@rpushpa
Copy link
Author

rpushpa commented May 27, 2015

Yes I get same erro telling the same for issue:

FAILED: Parse Error: line 4:2 mismatched input 'data' expecting Identifier near ',' in column specification

Thanks ,
Pushpa

@mtoupsUNO
Copy link

Oh, data could be a reserved keyword. Try wrapping it in backticks, i.e.

`data` array<struct<...>>

@telebh
Copy link

telebh commented Dec 22, 2021

I am trying to generate jar files using "mvn package" but it always freezes as follows. Please can you advise?

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for net.thornydev:json-hive-schema:jar:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 13, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -------------------< net.thornydev:json-hive-schema >-------------------
[INFO] Building json-hive-schema 1.0
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from nexus: http://nexus.elsst.com/content/groups/public/org/apache/maven/plugins/maven-assembly-plugin/2.4/maven-assembly-plugin-2.4.jar
Progress (1): 25/226 kB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants