Reputation: 43
I have executed a query in HIVE CLI that should generate an External Table . "create EXTERNAL TABLE IF NOT EXISTS hassan( code int, area_name string, male_60_64 STRUCT, male_above_65 STRUCT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';"
It works fine but if I put "-" instead of "_" I will face with error.
"create EXTERNAL TABLE IF NOT EXISTS hassan ( code int, area_name string, male-60-64 STRUCT< c1 : string, x-user : string>) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';"
Any help would be greatly appreciated.
Upvotes: 2
Views: 5392
Reputation: 21561
The answer by Addy already provided an example of how to use a hyphen in a column name. Here is an addition that describes how this works in different versions of Hive, according to the documentation:
In addition to that, you can also find the syntax for STRUCT there, which should help you with the error that you mentioned in the comments:
struct_type : STRUCT < col_name : data_type [COMMENT col_comment], ...>
Note that hyphens in complex types (so inside structs) do not appear to be supported.
Upvotes: 2
Reputation: 2415
Try Quoted Identifiers
create table hassan( code int, `area_name` string, `male-60-64` STRUCT, `male-above-65` STRUCT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
Reference:
https://issues.apache.org/jira/secure/attachment/12618321/QuotedIdentifier.html
Upvotes: 1