Skip to content

Conversation

@suxiaogang223
Copy link
Contributor

@suxiaogang223 suxiaogang223 commented Jan 19, 2026

suxiaogang223 and others added 2 commits January 16, 2026 15:06
…comprehensive test coverage (apache#59917)

- Related Pr: apache#51727
### What problem does this PR solve?

## Overview
This PR improves Iceberg table branch/tag functionality by adding input
parameter validation, optimizing snapshot loading logic, and
significantly expanding test coverage.

## Iceberg Logic Modifications

### 1. Optimize Snapshot Loading
**File**:
`fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java`

- Modified `loadSnapshots` method signature to accept `specificTable`
parameter
- Supports loading snapshot for a specific table instead of iterating
through all tables
- Caller (`BindRelation.java:419`) passes the concrete table object,
improving performance and precision

### 2. Enhanced Parameter Validation
**File**:
`fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java`

Added parameter validation for branch/tag creation operations:
- `RETAIN` time value must be greater than 0
- `SNAPSHOTS` (minimum snapshots to keep) must be greater than 0
- `RETENTION` time must be greater than 0
- Throws clear `IllegalArgumentException` with descriptive error
messages

### 3. Branch/Tag Name Validation
**File**:
`fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java`

- Validate branch name is not empty when creating a branch
- Validate tag name is not empty when creating a tag
- Throws `UserException` to notify users

### 4. Syntax Support Limitation
**File**:
`regression-test/suites/external_table_p0/iceberg/iceberg_branch_tag_operate.groovy`

Clarified that `CREATE OR REPLACE BRANCH IF NOT EXISTS` syntax
combination is not supported

## New Test Case Coverage

This PR adds 10 comprehensive test suites covering the following
scenarios:

| Test File | Coverage |
|-----------|----------|
| `iceberg_branch_complex_queries.groovy` | Complex query scenarios with
branch operations |
| `iceberg_branch_cross_operations.groovy` | Cross operations between
branches and tags |
| `iceberg_branch_partition_operations.groovy` | Partition-related
branch operations |
| `iceberg_branch_retention_and_snapshot.groovy` | Snapshot expiration
and retention policies |
| `iceberg_branch_tag_auth.groovy` | Branch/tag permission and
authorization |
| `iceberg_branch_tag_edge_cases.groovy` | Edge cases and exception
handling |
| `iceberg_branch_tag_parallel_op.groovy` | Concurrent/parallel
operations testing |
| `iceberg_branch_tag_schema_change_extended.groovy` | Schema change
scenarios |
| `iceberg_branch_tag_system_tables.groovy` | System table query
verification |
| `iceberg_tag_retention_and_consistency.groovy` | Tag consistency
validation |

## Improvements

- **More precise snapshot loading**: Avoids unnecessary full table
iteration
- **Stronger parameter validation**: Catches configuration errors early
with clear error messages
- **Comprehensive test coverage**: Multi-dimensional validation from
edge cases to concurrent operations

Co-authored-by: zgxme <u143@qq.com>
@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 external

@suxiaogang223
Copy link
Contributor Author

run buildall

@morningman
Copy link
Contributor

LGTM

@yiguolei yiguolei merged commit 414296c into apache:branch-4.0 Jan 21, 2026
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants