Alter Table Partitions
ALTER TABLE table_name ADD [IF NOT EXISTS]
(PARTITION part_spec [LOCATION path], ...)
part_spec:
: (part_col_name1=val1, part_col_name2=val2, ...)
Add partitions to the table, optionally with a custom location for each partition added. This is supported only for tables created using the Hive format. However, beginning with Spark 2.1, Alter Table Partitions
is also supported for tables defined using the datasource API.
IF NOT EXISTS
- If the specified partitions already exist, nothing happens.
ALTER TABLE table_name PARTITION part_spec RENAME TO PARTITION part_spec
part_spec:
: (part_col_name1=val1, part_col_name2=val2, ...)
Change the partitioning field values of a partition. This operation is allowed only for tables created using the Hive format.
ALTER TABLE table_name DROP [IF EXISTS] (PARTITION part_spec, ...)
part_spec:
: (part_col_name1=val1, part_col_name2=val2, ...)
Drop a partition from a table or view. This operation is allowed only for tables created using the Hive format.
IF EXISTS
- If the specified partition does not exists, nothing happens.
ALTER TABLE table_name PARTITION part_spec SET LOCATION path
part_spec:
: (part_col_name1=val1, part_col_name2=val2, ...)
Set the location of the specified partition. Setting the location of individual partitions is allowed only for tables created using the Hive format.