[spark][flink] Support primary-key vector search#8581
Open
JingsongLi wants to merge 7 commits into
Open
Conversation
Open
7 tasks
leaves12138
approved these changes
Jul 12, 2026
leaves12138
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the latest head. The Spark primary-key vector path now uses the Core primary-key read flow, score propagation is preserved through the generic score reader, and the metadata-only shortcut is correctly avoided for physical-position results. The merge-engine and deletion-vector validation changes are consistent with the corresponding read semantics.\n\nFocused verification passed:\n- Core primary-key vector and score-reader tests: 35 tests\n- Spark PrimaryKeyVectorSearchTest: 5 tests\n- Flink VectorSearchProcedureITCase: 7 tests
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.
Summary
Add end-to-end Spark SQL and Flink procedure support for primary-key vector search backed by the bucket-local indexes introduced in #8579. The PR supports every primary-key merge engine, distributes sufficiently large Spark searches by bucket group, and documents table creation, index maintenance, compaction freshness, query APIs, and current limitations.
Changes
SparkPrimaryKeyVectorRead, while Data Evolution tables use the renamedSparkDataEvolutionVectorRead.PrimaryKeyVectorReadand creating file readers, ANN searchers, and executors per task invocation.ScoreRecordReaderso Spark metadata handling depends on a shared score-reader contract instead of a concrete reader implementation.deduplicate,partial-update,aggregation, andfirst-rowmerge engines by indexing their complete Level-1 compact output.deduplicate,partial-update, andaggregation, whilefirst-rowrequires deletion vectors to be disabled.vector_searchIT coverage and a primary-key vector index guide underdocs/docs/primary-key-table/.Behavior
vector_searchreturns physical rows and__paimon_search_scorefrom one captured snapshot.spark.paimon.vector-search.distribute.enabled=true, sufficiently large bucket plans run as Spark task groups. Each task returns only its local Top-K and the driver performs the final deterministic global Top-K merge; small plans keep the Core local path to avoid Spark startup overhead.CALL sys.vector_searchuses the same Core primary-key vector search path and returns projected rows as JSON.deduplicateindexes the retained physical row, andpartial-updateindexes the lookup-completed row.aggregationindexes the aggregated Level-1 row;first-rowindexes the retained first row and ignores later rows with the same primary key.first-row, whose later duplicates are ignored instead of replacing the retained row.Testing
PrimaryKeyVectorSearchTest: 7 tests covering distributed reader routing, a real Spark ANN job, global Top-K across four buckets/two task groups, score projection, partition pruning, DEDUPLICATE updates/deletes, and PARTIAL_UPDATE completion.SparkDataEvolutionVectorReadTest: 3 existing distributed index/raw/refine tests after the reader rename.VectorSearchOptionsTest: existing Data Evolution query-option and metadata-only path.VectorSearchProcedureITCase: 7 tests with bothflink1andflink2profiles.PrimaryKeyVectorIndexValidationTestandPrimaryKeyVectorSearchTest: all merge engines, first-row with deletion vectors disabled, first-row plus deletion-vector rejection, and compact-output ANN semantics (22 tests).PrimaryKeyVectorReadTestandPrimaryKeyVectorSearchTest: local deterministic Top-K and bucket search regression coverage.PrimaryKeyVectorPositionReaderTestandIndexedSplitRecordReaderTest: 12 score-reader tests.git diff --check./concepts/overviewbroken-link warning, but the build and the new page succeed.Notes
Builds on #8579. This PR adds no new configuration keys or storage-format changes. Hybrid search and lateral/batch vector search remain outside its scope.