refactor: migrate filter pushdown from V1 Filter to V2 Predicate API#448
Open
wombatu-kun wants to merge 1 commit intolance-format:mainfrom
Open
refactor: migrate filter pushdown from V1 Filter to V2 Predicate API#448wombatu-kun wants to merge 1 commit intolance-format:mainfrom
wombatu-kun wants to merge 1 commit intolance-format:mainfrom
Conversation
Replace `SupportsPushDownFilters` with `SupportsPushDownV2Filters` in `LanceScanBuilder`, and migrate the downstream filter-analysis utilities (`FilterPushDown`, `RowAddressFilterAnalyzer`, `ZonemapFragmentPruner`) from the sealed `org.apache.spark.sql.sources.Filter` hierarchy to the extensible `org.apache.spark.sql.connector.expressions.filter.Predicate`. Why: V1 `Filter` is legacy in Spark 3.3+; V2 `Predicate` is the current recommended API and supports arbitrary named predicates, making future extensions (e.g. custom functions) straightforward. No external behavior changes — SQL filter semantics, zonemap pruning, `_rowaddr` fragment pruning, and the compiled SQL `WHERE` clause are preserved. Notable details: - V2 `Literal.value()` returns `UTF8String` for strings; normalized to `String` in `ZonemapFragmentPruner` before `compareTo` against zone min/max stats (which store native `String`). - Column access via `NamedReference.fieldNames()` joined with "." for nested paths (drop-in for V1 `Filter.references()` flat names). - Test helper `TestPredicates` builds canonical V2 predicates with the same shape Spark produces via `SupportsPushDownV2Filters`, including UTF8String/Date-epoch-days/Timestamp-epoch-micros conversion matching Spark's V2 literal representation. Regression: all 286 base-module unit tests pass unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
SupportsPushDownFilterswithSupportsPushDownV2FiltersinLanceScanBuilder, and migrate the downstream filter-analysis utilities (FilterPushDown,RowAddressFilterAnalyzer,ZonemapFragmentPruner) from the sealedorg.apache.spark.sql.sources.Filterhierarchy to the extensibleorg.apache.spark.sql.connector.expressions.filter.Predicate.Filteris legacy in Spark 3.3+; V2Predicateis the current recommended API and supports arbitrary named predicates, making future extensions (e.g. custom functions) straightforward._rowaddrfragment pruning, and the compiled SQLWHEREclause are preserved.Notable details
Literal.value()returnsUTF8Stringfor strings; normalized toStringinZonemapFragmentPrunerbeforecompareToagainst zone min/max stats (which store nativeString).NamedReference.fieldNames()joined with"."for nested paths (drop-in for V1Filter.references()flat names).TestPredicatesbuilds canonical V2 predicates with the same shape Spark produces viaSupportsPushDownV2Filters, including UTF8String/Date-epoch-days/Timestamp-epoch-micros conversion matching Spark's V2 literal representation.Test plan
make install— builds successfullymake test— 619 tests pass (0 failures, 0 errors)make lint— checkstyle + spotless pass🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com