JingsongLi commented on code in PR #7628:
URL: https://github.com/apache/paimon/pull/7628#discussion_r3459078414
##########
paimon-core/src/main/java/org/apache/paimon/utils/PartitionPredicateHelper.java:
##########
@@ -68,27 +85,36 @@ public static boolean applyPartitionFilter(
}
List<Predicate> andPredicates = new ArrayList<>();
for (int i = 0; i < partitionKeys.size(); i++) {
- Object value =
- TypeUtils.castFromString(
- partSpec.get(partitionKeys.get(i)),
partitionType.getTypeAt(i));
- andPredicates.add(partBuilder.equal(i, value));
+ String strValue = partSpec.get(partitionKeys.get(i));
+ if (defaultPartitionName.equals(strValue)) {
+ andPredicates.add(partBuilder.isNull(i));
+ } else {
+ Object value =
+ TypeUtils.castFromString(strValue,
partitionType.getTypeAt(i));
+ andPredicates.add(partBuilder.equal(i, value));
+ }
}
orPredicates.add(PredicateBuilder.and(andPredicates));
}
- if (!orPredicates.isEmpty()) {
-
snapshotReader.withPartitionFilter(PredicateBuilder.or(orPredicates));
- }
- } else if (partitionPredicate.function() instanceof
LeafBinaryFunction) {
+ return orPredicates.isEmpty()
+ ? PredicateBuilder.alwaysFalse()
+ : PredicateBuilder.or(orPredicates);
+ }
+ if (partitionPredicate.function() instanceof LeafBinaryFunction) {
LinkedHashMap<String, String> partSpec =
parsePartitionSpec(
partitionPredicate.literals().get(0).toString(),
partitionKeys);
- if (partSpec != null) {
- PredicateBuilder partBuilder = new
PredicateBuilder(partitionType);
- List<Predicate> predicates = new ArrayList<>();
- for (int i = 0; i < partitionKeys.size(); i++) {
- Object value =
- TypeUtils.castFromString(
- partSpec.get(partitionKeys.get(i)),
partitionType.getTypeAt(i));
+ if (partSpec == null) {
+ return PredicateBuilder.alwaysFalse();
+ }
+ PredicateBuilder partBuilder = new PredicateBuilder(partitionType);
+ List<Predicate> predicates = new ArrayList<>();
+ for (int i = 0; i < partitionKeys.size(); i++) {
+ String strValue = partSpec.get(partitionKeys.get(i));
+ if (defaultPartitionName.equals(strValue)) {
+ predicates.add(partBuilder.isNull(i));
+ } else {
+ Object value = TypeUtils.castFromString(strValue,
partitionType.getTypeAt(i));
Review Comment:
This conversion is not semantically equivalent for
`PartitionsTable.partition`, which is a string column like `pt=10` or
`dt=20260410/region=1`. For non-equality predicates the SQL predicate is
evaluated lexicographically on that full string, but this branch casts each
partition value to its physical type and ANDs the same binary function across
partition columns. For example, on an INT partition, `partition > "pt=2"`
should not match `pt=10` under string ordering (`"pt=10" < "pt=2"`), while the
pushed predicate becomes `pt > 2` and does match it. The catalog path filters
by testing the original string predicate, so the manifest fallback/time-travel
path can return different results. I think only equality/IN full-spec
predicates are safe to translate this way; other partition-string predicates
should skip pushdown unless the string semantics can be preserved.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]