Skip to content

Commit dbe3c3d

Browse files
committed
prepare version 0.48.8-public
1 parent 0c66fa9 commit dbe3c3d

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.48.8-public] - 2024-08-12
4+
5+
### Enhancement
6+
- Introduced internal validation of compound predicate expressions, fixed logic when handling
7+
invalid or always true/false predicates, enhanced test coverage, and ensured stability and
8+
accuracy in complex query optimization.
9+
310
## [0.48.7-public] - 2024-08-07
411
### Enhancements
512
- **TableTunnel Configuration Optimization**: Introduced the `tags` attribute to `TableTunnel Configuration`, enabling users to attach custom tags to tunnel operations for enhanced logging and management. These tags are recorded in the tenant-level `information schema`.

CHANGELOG_CN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# 更新日志
2+
## [0.48.8-public] - 2024-08-12
3+
### 增强
4+
- 引入了对复合谓词表达式的内部验证,修复了处理无效或总是真/假谓词时的逻辑,增强了测试覆盖,确保了在复杂查询优化中的稳定性和准确性。
5+
26

37
## [0.48.7-public] - 2024-08-07
48

odps-sdk/odps-sdk-table-api/src/main/java/com/aliyun/odps/table/optimizer/predicate/CompoundPredicate.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.List;
66
import java.util.stream.Collectors;
77

8-
import com.aliyun.odps.utils.StringUtils;
98
import com.google.common.collect.ImmutableList;
109

1110
/**
@@ -41,8 +40,7 @@ public CompoundPredicate(Operator logicalOperator) {
4140
public CompoundPredicate(Operator logicalOperator, List<Predicate> predicates) {
4241
super(PredicateType.COMPOUND);
4342
this.logicalOperator = logicalOperator;
44-
this.predicates =
45-
predicates.stream().filter(this::validatePredicate).collect(Collectors.toList());
43+
this.predicates = predicates;
4644
if (logicalOperator == Operator.NOT && predicates.size() > 1) {
4745
throw new IllegalArgumentException("NOT operator should only have one operand");
4846
}
@@ -63,9 +61,7 @@ public static CompoundPredicate not(Predicate predicates) {
6361
}
6462

6563
public void addPredicate(Predicate predicate) {
66-
if (validatePredicate(predicate)) {
67-
predicates.add(predicate);
68-
}
64+
predicates.add(predicate);
6965
}
7066

7167
@Override
@@ -79,8 +75,11 @@ public String toString() {
7975

8076
// 对于 NOT 运算符,我们确保只有一个操作数
8177
if (logicalOperator == Operator.NOT) {
82-
sb.append(opStr).append(" ");
8378
Predicate predicate = predicates.get(0);
79+
if (!validatePredicate(predicate)) {
80+
return Predicate.NO_PREDICATE.toString();
81+
}
82+
sb.append(opStr).append(" ");
8483
if (predicate instanceof CompoundPredicate) {
8584
sb.append('(').append(predicate).append(')');
8685
} else {
@@ -91,6 +90,17 @@ public String toString() {
9190

9291
for (int i = 0; i < predicates.size(); i++) {
9392
Predicate currentPredicate = predicates.get(i);
93+
if (!validatePredicate(currentPredicate)) {
94+
if (logicalOperator == Operator.OR) {
95+
// A or true = true
96+
// 对于 or 谓词,如果有任意谓词是 true,则结果为 true
97+
return Predicate.NO_PREDICATE.toString();
98+
} else {
99+
// A and true = A
100+
// 对于 and 谓词,跳过子谓词为 true 的谓词
101+
continue;
102+
}
103+
}
94104
if (currentPredicate instanceof CompoundPredicate
95105
&& ((CompoundPredicate) currentPredicate).logicalOperator != this.logicalOperator) {
96106
sb.append('(').append(currentPredicate).append(')');

0 commit comments

Comments
 (0)