7

我已经以这样的配置单元格式将分区数据存储在 s3 中。

/bucket/date=2017-02-20 /bucket/date=2017-20-25

现在我正在运行来自 Athena 的以下查询以创建分区

CREATE EXTERNAL TABLE hive3( battery double, longitude double, application string, latitude double, device_id string, trip_id string, id int, accuracy double, PARTITIONED BY (date string) ) ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' WITH SERDEPROPERTIES ('serialization.format' = '1') LOCATION 's3://bucket/'

抛出以下异常

no viable alternative at input 'create external' (service: amazonathena; status code: 400; error code: invalidrequestexception; request id: 6a4e0852-f8b0-11e6-b606-e52f2622374b)

任何帮助,将不胜感激。

谢谢

4

1 回答 1

8

PARTITIONED BY (date string)应该在列定义范围之外

CREATE EXTERNAL TABLE hive3(
    battery double,
    longitude double,
    application string,
    latitude double,
    device_id string,
    trip_id string,
    id int,
    accuracy double
  )
PARTITIONED BY (date string) 
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
WITH SERDEPROPERTIES ('serialization.format' = '1') 
LOCATION 's3://bucket/'
于 2017-02-22T04:37:54.120 回答