0

我是 hive 新手,我正在创建一个具有以下属性的表,

CREATE EXTERNAL TABLE EXTTBL_Transactions
(
    TRANSACTION_ID varchar(70) COMMENT 'UniqueID, `Primary Key',
    DEFINITION_ID varchar(70) COMMENT 'Definition, Null Allowed',
    USER_ID varchar(70) COMMENT 'Contact id, Foreign Key',
    PURCHASE_DATETIME Timestamp COMMENT 'Saved dattime, Null Allowed',
    PURCHASE_AMOUNT FLOAT COMMENT 'Sum  value of number of product purchase,Null Allowed',
    INTERACTIONS_ID varchar(70) COMMENT 'Unique interaction id, Foreign Key',
    PRODUCT_DETAILS array<struct<PRODUCT_NAME:varchar(70),PRODUCT_PRICE:FLOAT>> COMMENT 'Product Details'
)
COMMENT 'Transaction details'
PARTITIONED BY (LOAD_DATE DATE)
row format delimited fields terminated by ','
lines terminated by '\n'
collection items terminated by '|'
map keys terminated by ':'
LOCATION 's3a://XXX/XXX//Transactions';  

在上面的代码中,我为产品详细信息创建了一个结构类型数组。我用“|”分隔每个产品详细信息 和 struct element by ':',但不知何故这会导致错误。

4

1 回答 1

1

移动回答。

顺序应该是FIELDS, COLLECTION ITEMS, MAP KEYS, 然后LINES

蜂巢 DDL

row_format
  : DELIMITED [FIELDS TERMINATED BY char [ESCAPED BY char]] [COLLECTION ITEMS TERMINATED BY char]
        [MAP KEYS TERMINATED BY char] [LINES TERMINATED BY char]
于 2018-04-23T13:18:59.270 回答