This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 62be0bd2acc Fix NOT BETWEEN on sharding column being routed as BETWEEN
(#39855)
62be0bd2acc is described below
commit 62be0bd2acc255702612fab596f6edafd0659968
Author: Eunbin Son <[email protected]>
AuthorDate: Tue Sep 22 23:20:39 2026 +0900
Fix NOT BETWEEN on sharding column being routed as BETWEEN (#39855)
Co-authored-by: Liang Zhang <[email protected]>
---
RELEASE-NOTES.md | 1 +
.../generator/impl/ConditionValueBetweenOperatorGenerator.java | 3 +++
.../impl/ConditionValueBetweenOperatorGeneratorTest.java | 10 ++++++++++
3 files changed, 14 insertions(+)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 87e401424b5..456db79dd3e 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -86,6 +86,7 @@
1. Sharding: Compute the Snowflake key generator epoch in UTC instead of the
JVM default timezone -
[#38932](https://github.com/apache/shardingsphere/pull/38932)
1. Sharding: Fix order-dependent data source intersection in Cartesian routing
- [#39407](https://github.com/apache/shardingsphere/pull/39407)
1. Sharding: Fix incorrect AVG(DISTINCT) merge result across shards -
[#39429](https://github.com/apache/shardingsphere/pull/39429)
+1. Sharding: Fix NOT BETWEEN on sharding column being routed as BETWEEN -
[#39855](https://github.com/apache/shardingsphere/pull/39855)
1. Sharding: Use configured sharding column name when checking UPDATE
assignments - [#39864](https://github.com/apache/shardingsphere/pull/39864)
1. Sharding: Fix INTERVAL sharding on one-sided range outside datetime bounds
- [#39862](https://github.com/apache/shardingsphere/pull/39862)
1. Sharding: Fix GROUP_CONCAT merge result when all values are NULL -
[#39860](https://github.com/apache/shardingsphere/pull/39860)
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
index 0284a759fcd..b256dcd7f4c 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
@@ -40,6 +40,9 @@ public final class ConditionValueBetweenOperatorGenerator
implements ConditionVa
@Override
public Optional<ShardingConditionValue> generate(final BetweenExpression
predicate, final HashColumn column, final List<Object> params, final
TimestampServiceRule timestampServiceRule) {
+ if (predicate.isNot()) {
+ return Optional.empty();
+ }
ConditionValue betweenConditionValue = new
ConditionValue(predicate.getBetweenExpr(), params);
ConditionValue andConditionValue = new
ConditionValue(predicate.getAndExpr(), params);
Optional<Comparable<?>> betweenValue =
betweenConditionValue.getValue();
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
index fc36af39484..f4cb507f07b 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
@@ -165,4 +165,14 @@ class ConditionValueBetweenOperatorGeneratorTest {
Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(), timestampServiceRule);
assertFalse(actual.isPresent());
}
+
+ @Test
+ void assertGenerateConditionValueWithNotBetween() {
+ ColumnSegment left = new ColumnSegment(0, 0, new
IdentifierValue("id"));
+ ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0,
1);
+ ExpressionSegment andSegment = new LiteralExpressionSegment(0, 0, 2);
+ BetweenExpression predicate = new BetweenExpression(0, 0, left,
betweenSegment, andSegment, true);
+ Optional<ShardingConditionValue> actual =
generator.generate(predicate, column, new LinkedList<>(), timestampServiceRule);
+ assertFalse(actual.isPresent());
+ }
}