I want to create an athena table from data stored in aws-s3. But in addition I also want an identity column. Since Athena uses presto sql engine, I ran the query written below in Athena but it was giving error code 400 : invalidrequestexception. Athena query written below :-
CREATE EXTERNAL TABLE `db_name`.`preprocessed` (
id bigint unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
`event_action` string
)
PARTITIONED BY (
`platform` string
`dateval` string
)
STORED AS PARQUET
LOCATION <S3-LOCATION>
tblproperties ("parquet.compress"="SNAPPY");
Here S3-LOCATION is the location of my parquet files where data is stored inside aws-s3. Maybe this is because, AUTO_INCREMENT is a problem for Athena since CREATE TABLE query only creates a table plan with the help of s3 data stored in parquet files instead of loading the data from s3. But if there is any way to add an identity column along with the s3 data, please mention the solution. It will be a lot of help for me here.
ORDER BYover all columns. This combined with good partitioning column will still execute in parallel. Something likerow_number() over (PARTITION BY some_good_partitioning_columns ORDER BY other_column_1, other_column_2, ..., other_column_150). (To be precise: you don't need toORDER BYon columns that youPARTITION BY). Also,rank()is a better choice thanrow_number(). Withrank()equal rows will get the same number assigned, so they will remain equal. - Piotr Findeisen