Skip to content

branch-4.0: [feature](iceberg) Support Partition Evolution DDL for Iceberg Tables (#57972)#58538

Merged
yiguolei merged 2 commits intoapache:branch-4.0from
suxiaogang223:impl_iceberg_partition_ddl
Dec 2, 2025
Merged

branch-4.0: [feature](iceberg) Support Partition Evolution DDL for Iceberg Tables (#57972)#58538
yiguolei merged 2 commits intoapache:branch-4.0from
suxiaogang223:impl_iceberg_partition_ddl

Conversation

@suxiaogang223
Copy link
Contributor

bp: #57972

suxiaogang223 and others added 2 commits November 30, 2025 23:14
…apache#57972)

This PR implements support for partition evolution in Iceberg tables,
allowing users to dynamically modify table partition strategies without
rewriting data files. This is a metadata-only operation that maintains
multiple partition spec versions.

Apache Iceberg supports partition evolution, which enables changing
partition strategies on existing tables without data migration. Doris,
as a query engine for Iceberg, needs to support SQL syntax for partition
evolution operations to provide users with flexible partition
management.

- **Add Partition Field**: Add new partition field to existing partition
specifications
- **Drop Partition Field**: Remove partition field from existing
partition specifications
- **Replace Partition Field**:Replace partition field from existing
partition specifications with new partition field

1. **Metadata-only operation**: Partition evolution only updates table
metadata, no data files are rewritten
2. **Backward compatibility**: Historical data retains original
partition specs, new data uses new partition specs
3. **Syntax compatibility**: Follows Spark SQL ALTER TABLE syntax for
consistency

```sql
-- use optional AS keyword to specify a custom name for the partition field
ALTER TABLE table_name ADD PARTITION KEY partition_transform [AS key_name];

-- example
ALTER TABLE prod.db.sample ADD PARTITION KEY bucket(16, id);
ALTER TABLE prod.db.sample ADD PARTITION KEY truncate(4, data);
ALTER TABLE prod.db.sample ADD PARTITION KEY year(ts);
-- use optional AS keyword to specify a custom name for the partition field
ALTER TABLE prod.db.sample ADD PARTITION KEY bucket(16, id) AS shard;
```

```sql
ALTER TABLE table_name DROP PARTITION KEY partition_transform|key_name;

-- example
ALTER TABLE prod.db.sample DROP PARTITION KEY catalog;
ALTER TABLE prod.db.sample DROP PARTITION KEY bucket(16, id);
ALTER TABLE prod.db.sample DROP PARTITION KEY truncate(4, data);
ALTER TABLE prod.db.sample DROP PARTITION KEY year(ts);
ALTER TABLE prod.db.sample DROP PARTITION KEY shard;
```

```sql
-- use optional AS keyword to specify a custom name for the partition field
ALTER TABLE table_name REPLACE PARTITION KEY key_name WITH partition_transform [AS key_name];

-- example
ALTER TABLE prod.db.sample REPLACE PARTITION KEY ts_day WITH day(ts);
-- use optional AS keyword to specify a custom name for the new partition field
ALTER TABLE prod.db.sample REPLACE PARTITION KEY ts_day WITH day(ts) AS day_of_ts;
```

| Transform | Syntax | Example |
|-----------|--------|---------|
| bucket | `bucket(N, column)` | `bucket(16, id)` |
| truncate | `truncate(N, column)` | `truncate(10, name)` |
| year | `year(column)` | `year(ts)` |
| month | `month(column)` | `month(ts)` |
| day | `day(column)` | `day(ts)` |
| hour | `hour(column)` | `hour(ts)` |
| identity | `column` | `category` |
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@suxiaogang223
Copy link
Contributor Author

run buildall

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Dec 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit a6e83c9 into apache:branch-4.0 Dec 2, 2025
24 of 25 checks passed
@suxiaogang223 suxiaogang223 deleted the impl_iceberg_partition_ddl branch December 5, 2025 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments