[core] Fix BranchesTable returning empty result for non Equal/IN predicates#7848
Merged
JingsongLi merged 2 commits intoMay 14, 2026
Conversation
fbeb091 to
3044600
Compare
…icates
BranchesRead#withFilter is currently a // TODO, and BranchesRead#branches()
only handles two scan-side fast paths (Equal and OR-IN on branch_name)
inside if (predicate != null) with no fallback. As a result, any caller
that pushes a non-Equal/IN predicate into BranchesRead gets an empty
result instead of "list all and let the post-filter refine":
ReadBuilder rb = branchesTable.newReadBuilder()
.withFilter(builder.notEqual(0, BinaryString.fromString("b2")));
// returns 0 rows on master, should return all branches except b2
Today this is a latent issue at the SQL layer: Flink does not push
<>, LIKE, or cross-field OR into the paimon source for system tables,
so the filter is applied above the source and users see correct
results. But the InnerTableRead contract is still broken, and any
future caller (other engines, custom readers, or expanded Flink
push-down) that hands such a predicate to BranchesRead will silently
lose data.
Fix:
* drop the implicit else: each fast path now returns as soon as it
fully consumes the predicate, and the listing loop sits at the end
of the method, reached by any predicate shape no fast path can
answer (Equal on a different field, AND, NotEqual, LIKE, etc.);
* tighten the OR fast path so it only short-circuits when
InPredicateVisitor can actually flatten the OR back to an IN over
branch_name; otherwise fall through to the listing fallback;
* implement BranchesRead#withFilter as a read-side post-filter that
evaluates the predicate on the materialized row before projection.
Tests:
* BranchesTableTest drives InnerTableRead directly via PredicateBuilder
(the bug is reproducible there: testReadWithBranchNameNotEqualFilter
fails on master, passes after the fix).
* BranchSqlITCase#testBranchesTableFilter is extended with <>, LIKE,
and "OR that is not an IN" cases. These also pass on master since
Flink does not push these predicates down today; included as smoke
tests to ensure the fix does not break the planner-level fallback
path.
3044600 to
3490ad9
Compare
Contributor
|
+1 |
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.
Purpose
BranchesRead#withFilteris a// TODO, andBranchesRead#branches()only handles
Equal/ OR-IN onbranch_nameinsideif (predicate != null)with no else. Pushing any other predicateinto
BranchesReadreturns an empty result: