-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[python] Support filter by _ROW_ID for data evolution #7252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JingsongLi
merged 8 commits into
apache:master
from
XiaoHongbo-Hope:support_filter_by_row_id
Feb 11, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3427f8f
[python] support filter by _ROW_ID for data evolution
e333c97
[python] Add filter by _ROW_ID support
fadbca4
make remove_row_id_filter handle OR predicates with mixed fields
22321d0
clean code
361d998
add filter by row id case
5da22d5
fix empty row_ranges excluding all issue
f4414fe
clean code
f45abf1
support between and add test case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| ################################################################################ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ################################################################################ | ||
|
|
||
| import unittest | ||
|
|
||
| from pypaimon.common.predicate import Predicate | ||
| from pypaimon.globalindex.range import Range | ||
| from pypaimon.read.scanner.file_scanner import _row_ranges_from_predicate | ||
| from pypaimon.table.special_fields import SpecialFields | ||
|
|
||
|
|
||
| class RangeTest(unittest.TestCase): | ||
|
|
||
| def test_to_ranges(self): | ||
| assert Range.to_ranges([]) == [] | ||
| assert Range.to_ranges([5]) == [Range(5, 5)] | ||
| assert Range.to_ranges([1, 2, 3]) == [Range(1, 3)] | ||
| assert Range.to_ranges([1, 3, 5]) == [ | ||
| Range(1, 1), Range(3, 3), Range(5, 5) | ||
| ] | ||
| assert Range.to_ranges([1, 1, 2]) == [Range(1, 1), Range(1, 2)] | ||
|
|
||
| def test_row_ranges_from_predicate(self): | ||
| assert _row_ranges_from_predicate(None) is None | ||
|
|
||
| pred_eq = Predicate('equal', 0, SpecialFields.ROW_ID.name, [5]) | ||
| assert _row_ranges_from_predicate(pred_eq) == [Range(5, 5)] | ||
|
|
||
| pred_in = Predicate('in', 0, SpecialFields.ROW_ID.name, [10]) | ||
| assert _row_ranges_from_predicate(pred_in) == [Range(10, 10)] | ||
| pred_in_multi = Predicate('in', 0, SpecialFields.ROW_ID.name, [1, 2, 3, 5, 6]) | ||
| assert _row_ranges_from_predicate(pred_in_multi) == [Range(1, 3), Range(5, 6)] | ||
|
|
||
| pred_between = Predicate('between', 0, SpecialFields.ROW_ID.name, [10, 20]) | ||
| result = _row_ranges_from_predicate(pred_between) | ||
| assert result is not None and result == [Range(10, 20)] | ||
|
|
||
| pred_other = Predicate('equal', 0, 'other_field', [5]) | ||
| assert _row_ranges_from_predicate(pred_other) is None | ||
|
|
||
| pred_gt = Predicate('greaterThan', 0, SpecialFields.ROW_ID.name, [10]) | ||
| assert _row_ranges_from_predicate(pred_gt) is None | ||
|
|
||
| assert _row_ranges_from_predicate( | ||
| Predicate('equal', 0, SpecialFields.ROW_ID.name, []) | ||
| ) == [] | ||
| assert _row_ranges_from_predicate( | ||
| Predicate('in', 0, SpecialFields.ROW_ID.name, []) | ||
| ) == [] | ||
| assert _row_ranges_from_predicate( | ||
| Predicate('between', 0, SpecialFields.ROW_ID.name, [10]) | ||
| ) == [] | ||
|
|
||
| pred_eq5 = Predicate('equal', 0, SpecialFields.ROW_ID.name, [5]) | ||
| pred_between_1_10 = Predicate('between', 0, SpecialFields.ROW_ID.name, [1, 10]) | ||
| pred_and = Predicate('and', None, None, [pred_eq5, pred_between_1_10]) | ||
| assert _row_ranges_from_predicate(pred_and) == [Range(5, 5)] | ||
| pred_eq3 = Predicate('equal', 0, SpecialFields.ROW_ID.name, [3]) | ||
| pred_and_no = Predicate('and', None, None, [pred_eq5, pred_eq3]) | ||
| assert _row_ranges_from_predicate(pred_and_no) == [] | ||
|
|
||
| pred_or = Predicate('or', None, None, [pred_eq5, pred_eq3]) | ||
| assert _row_ranges_from_predicate(pred_or) == [Range(3, 3), Range(5, 5)] | ||
| pred_between_1_5 = Predicate('between', 0, SpecialFields.ROW_ID.name, [1, 5]) | ||
| pred_between_3_7 = Predicate('between', 0, SpecialFields.ROW_ID.name, [3, 7]) | ||
| pred_or_overlap = Predicate('or', None, None, [pred_between_1_5, pred_between_3_7]) | ||
| assert _row_ranges_from_predicate(pred_or_overlap) == [Range(1, 7)] | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And between, see #7255