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 Feb 2, 2026
Conversation
…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
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
yiguolei
approved these changes
Feb 2, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #59716