Hive错误:编译语句:FAILED:ParseException 15:0在''\ n''附近'collection'处缺少EOF

时间:2018-04-23 07:42:42

标签: hadoop hive hiveql hive-query

我是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类型数组。我将每个产品细节与'|'分开和'struct'结构元素,但不知何故这会导致错误。

1 个答案:

答案 0 :(得分:1)

转而回答。

订单应为FIELDSCOLLECTION ITEMSMAP KEYS,然后是LINES

Hive 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]