You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "jerry-024 (via GitHub)" <gi...@apache.org> on 2025/09/04 07:12:17 UTC
[PR] [core]fix: filter contains partition filter [paimon]
jerry-024 opened a new pull request, #6197:
URL: https://github.com/apache/paimon/pull/6197
<!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
### Purpose
For the format table: a user may define partition filters in filters, so we need to get partition filters from filters when a user defines filters for reading
<!-- What is the purpose of the change -->
### Tests
- CatalogTestBase#testFormatTableRead
<!-- List UT and IT cases to verify this change -->
### API and Format
<!-- Does this change affect API or storage format -->
### Documentation
<!-- Does this change introduce a new feature -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core]fix: filter contains partition filter [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #6197:
URL: https://github.com/apache/paimon/pull/6197
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core]fix: filter contains partition filter [paimon]
Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #6197:
URL: https://github.com/apache/paimon/pull/6197#discussion_r2321117831
##########
paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java:
##########
@@ -79,10 +81,27 @@ public RowType readType() {
@Override
public ReadBuilder withFilter(Predicate predicate) {
- if (this.filter == null) {
- this.filter = predicate;
- } else {
- this.filter = PredicateBuilder.and(this.filter, predicate);
+ int[] fieldIdxToPartitionIdx =
+ PredicateBuilder.fieldIdxToPartitionIdx(table.rowType(), table.partitionKeys());
+ Pair<List<Predicate>, List<Predicate>> partitionAndNonPartitionFilter =
+ splitAndForPartitionAndNonPartitionFilter(predicate, fieldIdxToPartitionIdx);
+ List<Predicate> partitionFilters = partitionAndNonPartitionFilter.getLeft();
+ List<Predicate> unPartitionFilters = partitionAndNonPartitionFilter.getRight();
+ if (partitionFilters.size() > 0 && this.partitionFilter == null) {
+ RowType partitionType = table.rowType().project(table.partitionKeys());
+ PartitionPredicate partitionPredicate =
+ PartitionPredicate.fromPredicate(
+ partitionType, PredicateBuilder.and(partitionFilters));
+ withPartitionFilter(partitionPredicate);
+ }
+
+ if (unPartitionFilters.size() > 0) {
Review Comment:
nonPartitionFilters?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core]fix: filter contains partition filter [paimon]
Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #6197:
URL: https://github.com/apache/paimon/pull/6197#discussion_r2321125200
##########
paimon-core/src/main/java/org/apache/paimon/table/format/FormatReadBuilder.java:
##########
@@ -79,10 +81,27 @@ public RowType readType() {
@Override
public ReadBuilder withFilter(Predicate predicate) {
- if (this.filter == null) {
- this.filter = predicate;
- } else {
- this.filter = PredicateBuilder.and(this.filter, predicate);
+ int[] fieldIdxToPartitionIdx =
+ PredicateBuilder.fieldIdxToPartitionIdx(table.rowType(), table.partitionKeys());
+ Pair<List<Predicate>, List<Predicate>> partitionAndNonPartitionFilter =
+ splitAndForPartitionAndNonPartitionFilter(predicate, fieldIdxToPartitionIdx);
+ List<Predicate> partitionFilters = partitionAndNonPartitionFilter.getLeft();
+ List<Predicate> unPartitionFilters = partitionAndNonPartitionFilter.getRight();
+ if (partitionFilters.size() > 0 && this.partitionFilter == null) {
Review Comment:
Can you check this.partitionFilter first?
I think we can do this splitting in scan method, just like ReadBuilderImpl. In case multiple times withFilter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core]fix: filter contains partition filter [paimon]
Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #6197:
URL: https://github.com/apache/paimon/pull/6197#discussion_r2321115143
##########
paimon-common/src/main/java/org/apache/paimon/predicate/PredicateBuilder.java:
##########
@@ -207,6 +208,21 @@ public static List<Predicate> splitAnd(@Nullable Predicate predicate) {
return result;
}
+ public static Pair<List<Predicate>, List<Predicate>> splitAndForPartitionAndNonPartitionFilter(
Review Comment:
Name too long, can you make it shorter? Just splitFilter with comment is fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [core]fix: filter contains partition filter [paimon]
Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #6197:
URL: https://github.com/apache/paimon/pull/6197#discussion_r2321119670
##########
paimon-core/src/main/java/org/apache/paimon/table/source/snapshot/SnapshotReaderImpl.java:
##########
@@ -222,24 +221,16 @@ public SnapshotReader withFilter(Predicate predicate) {
int[] fieldIdxToPartitionIdx =
PredicateBuilder.fieldIdxToPartitionIdx(
tableSchema.logicalRowType(), tableSchema.partitionKeys());
-
- List<Predicate> partitionFilters = new ArrayList<>();
- List<Predicate> nonPartitionFilters = new ArrayList<>();
- for (Predicate p : PredicateBuilder.splitAnd(predicate)) {
- Optional<Predicate> mapped = transformFieldMapping(p, fieldIdxToPartitionIdx);
- if (mapped.isPresent()) {
- partitionFilters.add(mapped.get());
- } else {
- nonPartitionFilters.add(p);
- }
- }
-
+ Pair<List<Predicate>, List<Predicate>> partitionAndNonPartitionFilter =
+ splitAndForPartitionAndNonPartitionFilter(predicate, fieldIdxToPartitionIdx);
+ List<Predicate> partitionFilters = partitionAndNonPartitionFilter.getLeft();
+ List<Predicate> unPartitionFilters = partitionAndNonPartitionFilter.getRight();
if (partitionFilters.size() > 0) {
scan.withPartitionFilter(PredicateBuilder.and(partitionFilters));
}
- if (nonPartitionFilters.size() > 0) {
- nonPartitionFilterConsumer.accept(scan, PredicateBuilder.and(nonPartitionFilters));
+ if (unPartitionFilters.size() > 0) {
Review Comment:
nonPartitionFilters
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org