About Me

My photo
Software Engineer at Starburst. Maintainer at Trino. Previously at LINE, Teradata, HPE.

2019-04-20

INSERT OVERWRITE in Presto

If you are hive user and ETL developer, you may see a lot of INSERT OVERWRITE. Though it's not yet documented, Presto also supports OVERWRITE mode for partitioned table.

Currently, there are 3 modes, OVERWRITE, APPEND and ERROR.

OVERWRITE overwrites existing partition.
APPEND appends rows in existing partition.
ERROR fails when the partition already exists.

You can change the mode by set session command.
set session hive.insert_existing_partitions_behavior = 'overwrite';
set session hive.insert_existing_partitions_behavior = 'append';
set session hive.insert_existing_partitions_behavior = 'error';

The enhanced feature for an unpartitioned table is ongoing in this PR (https://github.com/prestosql/presto/pull/648) by James Xu.

The enhancement was merged as https://github.com/prestosql/presto/pull/924