alpass163 commented on code in PR #16917:
URL: https://github.com/apache/iotdb/pull/16917#discussion_r2626004572


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/visitor/predicate/ConvertPredicateToFilterVisitor.java:
##########
@@ -265,7 +272,131 @@ private <T extends Comparable<T>> Filter 
constructCompareFilter(
       Context context) {
     PartialPath path = ((TimeSeriesOperand) timeseriesOperand).getPath();
     int measurementIndex = context.getMeasurementIndex(path.getMeasurement());
-    TSDataType dataType = context.getType(path);
+    TSDataType columnDataType = context.getType(path);
+
+    ConstantOperand constantLiteral = (ConstantOperand) constantOperand;
+    TSDataType constantDataType = constantLiteral.getDataType();
+    if (constantDataType == DOUBLE) {
+      String constantString = constantLiteral.getValueString();
+      BigDecimal constantDecimal = new BigDecimal(constantString);
+
+      if (columnDataType == INT64) {
+        if (constantDecimal.compareTo(new BigDecimal(Long.MAX_VALUE)) > 0) {
+          return constructFilterForGreaterThanMax(expressionType, 
measurementIndex);
+        }
+        if (constantDecimal.compareTo(new BigDecimal(Long.MIN_VALUE)) < 0) {
+          return constructFilterForLessThanMin(expressionType, 
measurementIndex);
+        }
+        return constructFilterFromDouble(
+            expressionType, constantOperand, measurementIndex, columnDataType);
+
+      } else if (columnDataType == INT32) {
+        if (constantDecimal.compareTo(new BigDecimal(Integer.MAX_VALUE)) > 0) {
+          return constructFilterForGreaterThanMax(expressionType, 
measurementIndex);
+        }
+        if (constantDecimal.compareTo(new BigDecimal(Integer.MIN_VALUE)) < 0) {
+          return constructFilterForLessThanMin(expressionType, 
measurementIndex);
+        }
+        return constructFilterFromDouble(
+            expressionType, constantOperand, measurementIndex, columnDataType);
+      }
+    }
+
+    if (constantDataType == INT64 && columnDataType == INT32) {
+      return constructValueFilter(expressionType, constantOperand, INT64, 
measurementIndex);
+    }

Review Comment:
   transforming the int32 to int64 is compatitable, and the long filter also 
allows int32 column



-- 
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]

Reply via email to