Skip to content

branch-4.0: [enhance](iceberg) Refactor Iceberg metadata cache structure and add table cache test cases #59716#60341

Merged
yiguolei merged 1 commit intobranch-4.0from
auto-pick-59716-branch-4.0
Feb 2, 2026
Merged

branch-4.0: [enhance](iceberg) Refactor Iceberg metadata cache structure and add table cache test cases #59716#60341
yiguolei merged 1 commit intobranch-4.0from
auto-pick-59716-branch-4.0

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #59716

…table cache test cases (#59716)

### What problem does this PR solve?

## Description

### Changes

This PR refactors the Iceberg metadata cache structure to improve code
organization and adds comprehensive test cases for table cache behavior.

### Main Changes

#### 1. Refactored IcebergMetadataCache

- Introduced `IcebergTableCacheValue` to encapsulate table-related
metadata
- Removed redundant `snapshotListCache` and `snapshotCache`
- Merged snapshot information into `IcebergTableCacheValue` with lazy
loading
- Simplified cache structure from 3 separate caches to 2: `tableCache`
and `viewCache`

**Before:**
```java
private LoadingCache<IcebergMetadataCacheKey, List<Snapshot>> snapshotListCache;
private LoadingCache<IcebergMetadataCacheKey, Table> tableCache;
private LoadingCache<IcebergMetadataCacheKey, IcebergSnapshotCacheValue> snapshotCache;
```

**After:**
```java
private LoadingCache<IcebergMetadataCacheKey, IcebergTableCacheValue> tableCache;
private LoadingCache<IcebergMetadataCacheKey, View> viewCache;
```

#### 2. Lazy Loading for Snapshot Cache

- Snapshot cache is now loaded on-demand through
`IcebergTableCacheValue.getSnapshotCacheValue()`
- Reduced unnecessary memory footprint for queries that don't require
snapshot information
- Snapshot information is mainly used for MTMV scenarios

#### 3. Simplified Cache API

- `getIcebergTable()`: Returns the Table object directly from
`IcebergTableCacheValue`
- `getSnapshotCache()`: Returns snapshot cache value with lazy loading
- `getSnapshotList()`: Returns snapshot list from the Table object

#### 4. Test Cases

- Added comprehensive test case `test_iceberg_table_cache` to verify
cache behavior
- Tests cover both cache-enabled and cache-disabled scenarios
- Validated external modifications (INSERT, DELETE, UPDATE, schema
changes) are properly handled

### Benefits

| Aspect | Improvement |
|--------|-------------|
| **Memory Usage** | Reduced by eliminating duplicate caching of
snapshot information |
| **Code Structure** | Cleaner with single `IcebergTableCacheValue`
instead of multiple separate caches |
| **Performance** | Better with lazy loading of snapshot cache only when
needed |
| **Maintainability** | Simpler cache management logic |

### Test Results

- Added regression test: `test_iceberg_table_cache.groovy`
- Tests validate cache behavior with TTL and external modifications
- Verified cache invalidation works correctly with `REFRESH TABLE`
- Test scenarios include:
  - DML operations (INSERT, DELETE, UPDATE, INSERT OVERWRITE)
  - Schema changes (ADD/DROP/RENAME COLUMN, ALTER COLUMN TYPE)
  - Partition evolution (ADD/DROP/REPLACE PARTITION FIELD)

### Related Files

**Core Changes:**
- `IcebergMetadataCache.java` - Refactored cache structure
- `IcebergTableCacheValue.java` - New class to encapsulate table
metadata
- `IcebergExternalCatalog.java` - Updated cache-related configurations

**Tests:**
- `test_iceberg_table_cache.groovy` - Comprehensive cache behavior tests
- `Suite.groovy` - Updated `getSparkIcebergContainerName()`
implementation
@github-actions github-actions bot requested a review from yiguolei as a code owner January 29, 2026 06:39
@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?

@dataroaring dataroaring reopened this Jan 29, 2026
@hello-stephen
Copy link
Contributor

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/92) 🎉
Increment coverage report
Complete coverage report

@yiguolei yiguolei merged commit 6f311cc into branch-4.0 Feb 2, 2026
25 of 28 checks passed
@github-actions github-actions bot deleted the auto-pick-59716-branch-4.0 branch February 2, 2026 03:18
ybtsdst pushed a commit to ybtsdst/doris that referenced this pull request Feb 27, 2026
…ure and add table cache test cases apache#59716 (apache#60341)

Cherry-picked from apache#59716

Co-authored-by: Socrates <suyiteng@selectdb.com>
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