Caideyipi commented on code in PR #17850:
URL: https://github.com/apache/iotdb/pull/17850#discussion_r4373907393
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/IrExpressionInterpreter.java:
##########
@@ -422,17 +426,21 @@ public Object visitInPredicate(InPredicate node, Object
context) {
// optimization
if (!inListCache.containsKey(valueList)) {
if
(valueList.getValues().stream().allMatch(Literal.class::isInstance)
- &&
valueList.getValues().stream().noneMatch(NullLiteral.class::isInstance)) {
+ &&
valueList.getValues().stream().noneMatch(NullLiteral.class::isInstance)
+ && valueList.getValues().stream()
+ .allMatch(item -> type(item).equals(type(node.getValue()))))
{
set =
valueList.getValues().stream()
.map(expr -> processWithExceptionHandling(expr, context))
+ // INT32 literals and folded arithmetic may use different
Java containers.
+ .map(item -> normalizeArithmeticValue(item,
type(node.getValue())))
.collect(Collectors.toSet());
}
inListCache.put(valueList, set);
}
if (set != null) {
- return set.contains(value);
+ return set.contains(normalizeArithmeticValue(value,
type(node.getValue())));
Review Comment:
Found and fixed in `939d153bdf9`: folded INT32 arithmetic can produce
`Integer` while an INT32 literal can produce `Long`, so raw `Set.contains` made
`1 + 1 IN (2, 3)` false. The IN cache now normalizes same-type values to the
SQL native container, and mixed SQL types use numeric comparison.
`testFoldedNumericInPredicates` covers both paths.
--
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]