使用athena创建分区时,在输入'create external'时没有可行的替代方法

时间:2017-02-22 03:46:59

标签: sql amazon-s3 hive amazon-athena

我已经以hive格式将分区数据存储在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)

任何帮助都将不胜感激。

由于

1 个答案:

答案 0 :(得分:6)

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/'