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 0a4423f6677 Route IN predicates without a sharding condition when an
item can't be evaluated (#40129)
0a4423f6677 is described below
commit 0a4423f6677dc4b674fc77b198818cc338988a09
Author: Hariom Lokhande
<[email protected]>
AuthorDate: Sat Oct 10 20:11:57 2026 +0530
Route IN predicates without a sharding condition when an item can't be
evaluated (#40129)
---
RELEASE-NOTES.md | 1 +
.../impl/ConditionValueInOperatorGenerator.java | 2 ++
.../impl/ConditionValueInOperatorGeneratorTest.java | 19 +++++++++++++++++++
3 files changed, 22 insertions(+)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 1a38e79c76b..f04be11d6ba 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -108,6 +108,7 @@
1. Sharding: Fix NULL ordering when merging ORDER BY results for ClickHouse
and Presto - [#40014](https://github.com/apache/shardingsphere/issues/40014)
1. Sharding: Rewrite generated ORDER BY column owners to actual table names -
[#39866](https://github.com/apache/shardingsphere/pull/39866)
1. Sharding: Reject sharding auto table configured with none sharding strategy
- [#39869](https://github.com/apache/shardingsphere/pull/39869)
+1. Sharding: Fix IN predicates with an expression item routing only to the
shards of the other items -
[#40128](https://github.com/apache/shardingsphere/issues/40128)
1. Readwrite-splitting: Evaluate inline expressions in data source names of
rule configuration checker -
[#39374](https://github.com/apache/shardingsphere/pull/39374)
1. SQL Federation: Fix SQL Federation pagination binding for long LIMIT
parameters - [#39237](https://github.com/apache/shardingsphere/pull/39237)
1. Broadcast: Fix case-sensitive table name lookup in broadcast data node rule
attribute - [#39153](https://github.com/apache/shardingsphere/pull/39153)
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
index 7585223bdcc..482c91260c9 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
@@ -61,7 +61,9 @@ public final class ConditionValueInOperatorGenerator
implements ConditionValueGe
}
if (ExpressionConditionUtils.isNowExpression(each)) {
shardingConditionValues.add(timestampServiceRule.getTimestamp());
+ continue;
}
+ return Optional.empty();
}
return shardingConditionValues.isEmpty() ? Optional.empty()
: Optional.of(new
ListShardingConditionValue<>(column.getName(), column.getTableName(),
shardingConditionValues, parameterMarkerIndexes));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
index 9eec1c64f51..fc75158bbd1 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
@@ -21,6 +21,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.HashColumn;
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
import
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
+import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.InExpression;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ListExpression;
import
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.complex.CommonExpressionSegment;
@@ -92,6 +93,24 @@ class ConditionValueInOperatorGeneratorTest {
assertThat(shardingConditionValue.get().toString(), is("tbl.id in
(test1,,,test2)"));
}
+ @Test
+ void assertCommonAndNotEvaluableExpression() {
+ ListExpression listExpression = new ListExpression(0, 0);
+ listExpression.getItems().add(new LiteralExpressionSegment(0, 0, 1));
+ listExpression.getItems().add(new BinaryOperationExpression(0, 0, new
LiteralExpressionSegment(0, 0, 2), new LiteralExpressionSegment(0, 0, 2), "+",
"2 + 2"));
+ InExpression inExpression = new InExpression(0, 0, null,
listExpression, false);
+ assertFalse(generator.generate(inExpression, column, new
LinkedList<>(), timestampServiceRule).isPresent());
+ }
+
+ @Test
+ void assertParameterAndNotEvaluableParameterExpression() {
+ ListExpression listExpression = new ListExpression(0, 0);
+ listExpression.getItems().add(new ParameterMarkerExpressionSegment(0,
0, 0));
+ listExpression.getItems().add(new BinaryOperationExpression(0, 0, new
ParameterMarkerExpressionSegment(0, 0, 1), new LiteralExpressionSegment(0, 0,
0), "+", "? + 0"));
+ InExpression inExpression = new InExpression(0, 0, null,
listExpression, false);
+ assertFalse(generator.generate(inExpression, column, Arrays.asList(1,
4), timestampServiceRule).isPresent());
+ }
+
@SuppressWarnings("unchecked")
@Test
void assertGenerateConditionValueWithParameter() {