[core][flink][spark] Refactor global index building and support incremental refresh - #8818
Conversation
86c6eb8 to
3c26b06
Compare
|
Older versions of the vector index are skipped by the refresh planner when |
|
The feature “automatically refresh the old vector index once after an upgrade” has not yet been implemented**. The old index lacks |
06f326e to
4277d12
Compare
|
@JingsongLi Thanks for pointing this out. The previous wording was inconsistent with the implemented behavior. After discussion, automatic migration of indexes created before I also updated the title and description to cover the broader global-index build refactoring included here: |
| | `global-index.external-path` | Not set | Root directory for global index files. If not set, files are stored under the table index directory. | | ||
| | `global-index.column-update-action` | `THROW_ERROR` | Action for updates to indexed columns. `THROW_ERROR` rejects the update, `DROP_PARTITION_INDEX` drops affected partition indexes, and `IGNORE` keeps existing index files unchanged. Use `IGNORE` only when a stale index is acceptable; for example, a vector updated from `NULL` to a value remains invisible until the index is rebuilt. | | ||
| | `global-index.column-update-action` | `THROW_ERROR` | Action for updates to indexed columns. `THROW_ERROR` rejects the update, `DROP_PARTITION_INDEX` drops affected partition indexes, and `IGNORE` keeps existing index files unchanged until the index is rebuilt. Set this to `IGNORE` together with `global-index.detect-datafile-change=true` to refresh affected row ranges during the next incremental index build. | | ||
| | `global-index.detect-datafile-change` | `false` | Whether incremental global index builds scan active data manifests to detect changes in already indexed row ranges. Enable this together with `global-index.column-update-action=IGNORE` to rebuild affected ranges. Index files created before this metadata was introduced are not refreshed automatically. | |
There was a problem hiding this comment.
Remove this option, just use IGNORE.
| + "IGNORE leaves existing index files unchanged and may make the index stale."); | ||
| + "IGNORE leaves existing index files unchanged during the update and enables a later incremental index build to refresh affected row ranges."); | ||
|
|
||
| public static final ConfigOption<Boolean> GLOBAL_INDEX_IGNORE_MISSING_DELETE = |
There was a problem hiding this comment.
Do we need this option?
|
Just one comment left |
074892b to
c2b4b8a
Compare
25cb830 to
756b522
Compare
|
+1 |
Purpose
This PR has two related goals:
Previously, generic and sorted index builders mixed scan planning, mutable build state, and index-file writing. Incremental builds also considered only uncovered row ranges, so an index could remain readable but become stale after partial updates to indexed columns.
Global-index build refactoring
ScanResult, which carries the scan snapshot ID, selected row ranges, scan entries, and index entries to delete.GenericGlobalIndexScannerand remove the Flink-specificGenericGlobalIndexBuilder.SortedGlobalIndexScannerandSortedGlobalIndexWriterso scan state is returned explicitly instead of retained in mutable builder fields.GlobalIndexBuilderUtils.scanandincrementalScanflows.ScanResultand keep index writing separate from scan planning.Data-evolution index refresh
scanSnapshotIdinGlobalIndexMeta.sourceMeta, encoded with aDEIXmagic number and version.global-index.detect-datafile-change=true, select an existing index for refresh when an active data file:maxSequenceNumbergreater than the index'sscanSnapshotId.global-index.ignore-missing-delete=trueenables permissive behavior when explicitly required.Data-file change detection is disabled by default because it requires scanning manifest entries. Existing uncovered-range incremental builds retain their previous behavior unless the option is enabled.
Compatibility and scope
Indexes created before
DEIXsource metadata was introduced do not have a trustworthy scan watermark. This PR intentionally does not perform automatic migration or a one-time refresh for those indexes. They remain treated as covered and must be explicitly rebuilt once to populatesourceMetabefore participating in change-based refresh.User impact
For data-evolution tables with change detection enabled, users can continuously update indexed columns and run incremental index builds. Unaffected ranges remain available, while affected ranges are rebuilt and atomically replace their previous index files. Updates to unrelated physical columns do not trigger a refresh.
Tests