feat: support deferred index creation with WITH (train=false)#558
Open
ivscheianu wants to merge 1 commit into
Open
feat: support deferred index creation with WITH (train=false)#558ivscheianu wants to merge 1 commit into
ivscheianu wants to merge 1 commit into
Conversation
Adds a train option to ALTER TABLE CREATE INDEX that skips data processing and commits an empty index, deferring population to a subsequent OPTIMIZE call.
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.
Problem
ALTER TABLE ... CREATE INDEXalways builds the index eagerly over all existing data before returning. On large datasets this is a long-running, blocking operation. There was no way to register an index definition without immediately training it, making it impossible to separate the "declare the index" step from the "populate it" step.Solution
Add a
trainoption to theWITHclause:When
train=false, no Spark tasks are launched and no data is processed. An empty index is committed directly on the driver with an empty fragment bitmap — all existing rows appear as unindexed. A subsequentOPTIMIZEcall covers them incrementally at a time of the caller's choosing.The default (
train=true) is unchanged, so all existing behaviour is preserved.As a side fix, Spark-level execution options (
train,build_mode,rows_per_range) are now filtered before being forwarded to the Lance index backend as index parameters.