Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No viable alternative at input 'create external' while creating partition using athena

I have stored partitioned data in s3 in hive format like this.

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

Now i am running following query from Athena to create partition

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

Throwing following exception

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

Any help would be appreciated.

Thanks

like image 647
Shailendra Avatar asked Feb 22 '17 03:02

Shailendra


1 Answers

PARTITIONED BY (date string) should be outside the columns definition scope

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/'
like image 107
David דודו Markovitz Avatar answered Oct 03 '22 04:10

David דודו Markovitz