This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch object_type
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 3ecf97310c87075fbbabefc648a0c562732cba96
Author: Weihao Li <[email protected]>
AuthorDate: Mon Jul 14 08:55:29 2025 +0800

    Make div and mod return long type if types of two inputs are all int64 or 
int32
    
    (cherry picked from commit ac44d8b85943185ceb66abdce8ac02348f9160c3)
---
 .../org/apache/iotdb/db/it/IoTDBNestedQueryIT.java |  4 +-
 .../db/it/aggregation/maxby/IoTDBMaxByIT.java      |  5 +-
 .../db/it/aggregation/minby/IoTDBMinByIT.java      |  5 +-
 .../IoTDBArithmeticDivAndModWithoutDoubleIT.java   | 70 ++++++++++++++++++++++
 .../withoutNull/IoTDBWithoutNullAllFilterIT.java   | 48 +++++++--------
 .../withoutNull/IoTDBWithoutNullAnyFilterIT.java   | 48 +++++++--------
 .../plan/analyze/ExpressionTypeAnalyzer.java       | 29 +++++++++
 .../visitor/ColumnTransformerVisitor.java          | 11 ++++
 .../db/queryengine/plan/analyze/AnalyzeTest.java   |  4 +-
 9 files changed, 168 insertions(+), 56 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
index ab289ef6aff..24df10c1ba9 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java
@@ -499,7 +499,7 @@ public class IoTDBNestedQueryIT {
           Assert.assertEquals(2 * i + 2.0D, rs.getDouble(3), 0.01);
           Assert.assertEquals(2 * i + 2.0D, rs.getDouble(4), 0.01);
           Assert.assertEquals(i / 2.0D + 0.5D, rs.getDouble(5), 0.01);
-          Assert.assertEquals(i / 2.0D + 0.5D, rs.getDouble(6), 0.01);
+          Assert.assertEquals((i / 2) + 1 / 2, rs.getDouble(6), 0.01);
         }
         Assert.assertFalse(rs.next());
       }
@@ -536,7 +536,7 @@ public class IoTDBNestedQueryIT {
         for (int i = 1; i <= ITERATION_TIMES; i++) {
           Assert.assertTrue(rs.next());
           Assert.assertEquals(i, rs.getLong(1));
-          Assert.assertEquals(2.0D - i / 2.0D, rs.getDouble(2), 0.01);
+          Assert.assertEquals(1.0D - i / 2 + 1, rs.getDouble(2), 0.01);
           Assert.assertEquals(1.5 - i / 2.0D, rs.getDouble(3), 0.01);
           Assert.assertEquals((1.0D / 3.0D) * (1.0D - i), rs.getDouble(4), 
0.01);
         }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/maxby/IoTDBMaxByIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/maxby/IoTDBMaxByIT.java
index 1ccdc8c1195..558cbe36d24 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/maxby/IoTDBMaxByIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/maxby/IoTDBMaxByIT.java
@@ -300,7 +300,7 @@ public class IoTDBMaxByIT {
             "max_by(root.db.d1.x5, -cos(sin(root.db.d1.y2 / 10)))",
             "max_by(REPLACE(root.db.d1.x6, '3', '4'), -cos(sin(root.db.d1.y2 / 
10)))",
           };
-      String[] retArray = new String[] {"1.0,2.0,3.0,3.0,false,4,"};
+      String[] retArray = new String[] 
{"0.0,1.3333333333333333,2.0,2.0,false,2,"};
       String y = "-cos(sin(y2 / 10))";
       resultSetEqualTest(
           String.format(
@@ -330,7 +330,8 @@ public class IoTDBMaxByIT {
           };
       String[] retArray =
           new String[] {
-            "root.db.d1,1.0,2.0,3.0,3.0,false,4,", 
"root.db.d2,1.0,2.0,3.0,3.0,false,4,"
+            "root.db.d1,0.0,1.3333333333333333,2.0,2.0,false,2,",
+            "root.db.d2,0.0,1.3333333333333333,2.0,2.0,false,2,"
           };
       String y = "-cos(sin(y2 / 10))";
       resultSetEqualTest(
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/minby/IoTDBMinByIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/minby/IoTDBMinByIT.java
index 82867e782cc..2d8bb1db5c8 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/minby/IoTDBMinByIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/minby/IoTDBMinByIT.java
@@ -300,7 +300,7 @@ public class IoTDBMinByIT {
             "min_by(root.db.d1.x5, -cos(sin(root.db.d1.y2 / 10)))",
             "min_by(REPLACE(root.db.d1.x6, '3', '4'), -cos(sin(root.db.d1.y2 / 
10)))",
           };
-      String[] retArray = new String[] {"1.0,2.0,3.0,3.0,false,4,"};
+      String[] retArray = new String[] 
{"0.0,1.3333333333333333,2.0,2.0,false,2,"};
       String y = "-cos(sin(y2 / 10))";
       resultSetEqualTest(
           String.format(
@@ -330,7 +330,8 @@ public class IoTDBMinByIT {
           };
       String[] retArray =
           new String[] {
-            "root.db.d1,1.0,2.0,3.0,3.0,false,4,", 
"root.db.d2,1.0,2.0,3.0,3.0,false,4,"
+            "root.db.d1,0.0,1.3333333333333333,2.0,2.0,false,2,",
+            "root.db.d2,0.0,1.3333333333333333,2.0,2.0,false,2,"
           };
       String y = "-cos(sin(y2 / 10))";
       resultSetEqualTest(
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticDivAndModWithoutDoubleIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticDivAndModWithoutDoubleIT.java
new file mode 100644
index 00000000000..aaeb210428f
--- /dev/null
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBArithmeticDivAndModWithoutDoubleIT.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.it.query;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
+import static org.apache.iotdb.itbase.constant.TestConstant.TIMESTAMP_STR;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBArithmeticDivAndModWithoutDoubleIT {
+  private static final String[] SQLs =
+      new String[] {
+        "CREATE DATABASE root.test",
+        "CREATE TIMESERIES root.test.sg1.s1 WITH DATATYPE=INT32, 
ENCODING=PLAIN",
+        "INSERT INTO root.test.sg1(time,s1) values(1752034015183000006, 
10001)",
+        "flush",
+      };
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    
EnvFactory.getEnv().getConfig().getCommonConfig().setTimestampPrecision("ns");
+    EnvFactory.getEnv().initClusterEnvironment();
+    prepareData(SQLs);
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void testArithmeticOperations() {
+    String[] expectedHeader =
+        new String[] {
+          TIMESTAMP_STR, "Time % 10", "Time / 10", "root.test.sg1.s1 % 10", 
"root.test.sg1.s1 / 10"
+        };
+    String[] retArray = new String[] 
{"1752034015183000006,6,175203401518300000,1,1000,"};
+    resultSetEqualTest(
+        "select time%10, time/10, s1%10, s1/10 from root.test.sg1", 
expectedHeader, retArray);
+  }
+}
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAllFilterIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAllFilterIT.java
index 1c550726db4..a5506836764 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAllFilterIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAllFilterIT.java
@@ -391,42 +391,42 @@ public class IoTDBWithoutNullAllFilterIT {
     System.out.println("withExpressionQueryTest");
     String[] retArray1 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     String[] retArray2 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
           "8,8,-8,null,null,null,null,null,null,null",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     String[] retArray3 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
           "8,8,-8,null,null,null,null,null,null,null",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     String[] retArray4 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
           "8,8,-8,null,null,null,null,null,null,null",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAnyFilterIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAnyFilterIT.java
index 5436381cc66..6d307dc96d8 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAnyFilterIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/withoutNull/IoTDBWithoutNullAnyFilterIT.java
@@ -356,39 +356,39 @@ public class IoTDBWithoutNullAnyFilterIT {
     System.out.println("withExpressionQueryTest");
     String[] retArray1 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     String[] retArray2 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     String[] retArray3 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     String[] retArray4 =
         new String[] {
-          "1,1,-1,1,1,2.0,0.0,1.0,1.0,0.0",
-          "2,2,-2,2,2,4.0,0.0,4.0,1.0,0.0",
-          "5,5,-5,5,5,10.0,0.0,25.0,1.0,0.0",
-          "6,6,-6,6,6,12.0,0.0,36.0,1.0,0.0",
-          "9,9,-9,9,9,18.0,0.0,81.0,1.0,0.0",
-          "10,10,-10,10,10,20.0,0.0,100.0,1.0,0.0"
+          "1,1,-1,1,1,2.0,0.0,1.0,1,0",
+          "2,2,-2,2,2,4.0,0.0,4.0,1,0",
+          "5,5,-5,5,5,10.0,0.0,25.0,1,0",
+          "6,6,-6,6,6,12.0,0.0,36.0,1,0",
+          "9,9,-9,9,9,18.0,0.0,81.0,1,0",
+          "10,10,-10,10,10,20.0,0.0,100.0,1,0"
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ExpressionTypeAnalyzer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ExpressionTypeAnalyzer.java
index 41f793d3362..adc80c7bb15 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ExpressionTypeAnalyzer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ExpressionTypeAnalyzer.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.db.queryengine.plan.analyze;
 import org.apache.iotdb.db.exception.sql.SemanticException;
 import org.apache.iotdb.db.queryengine.common.NodeRef;
 import org.apache.iotdb.db.queryengine.plan.expression.Expression;
+import org.apache.iotdb.db.queryengine.plan.expression.ExpressionType;
 import 
org.apache.iotdb.db.queryengine.plan.expression.binary.ArithmeticBinaryExpression;
 import 
org.apache.iotdb.db.queryengine.plan.expression.binary.CompareBinaryExpression;
 import 
org.apache.iotdb.db.queryengine.plan.expression.binary.LogicBinaryExpression;
@@ -245,6 +246,16 @@ public class ExpressionTypeAnalyzer {
           TSDataType.INT64,
           TSDataType.FLOAT,
           TSDataType.DOUBLE);
+      if ((arithmeticBinaryExpression.getExpressionType() == 
ExpressionType.DIVISION
+              || arithmeticBinaryExpression.getExpressionType() == 
ExpressionType.MODULO)
+          && isExpressionDataTypeSatisfy(
+              arithmeticBinaryExpression.getLeftExpression(), 
TSDataType.INT64, TSDataType.INT32)
+          && isExpressionDataTypeSatisfy(
+              arithmeticBinaryExpression.getRightExpression(),
+              TSDataType.INT64,
+              TSDataType.INT32)) {
+        return setExpressionType(arithmeticBinaryExpression, TSDataType.INT64);
+      }
       return setExpressionType(arithmeticBinaryExpression, TSDataType.DOUBLE);
     }
 
@@ -484,6 +495,24 @@ public class ExpressionTypeAnalyzer {
               "Invalid input expression data type. expression: %s, actual data 
type: %s, expected data type(s): %s.",
               expressionString, actual.name(), Arrays.toString(expected)));
     }
+
+    private boolean isExpressionDataTypeSatisfy(Expression input, 
TSDataType... expected) {
+      NodeRef<Expression> inputRef = NodeRef.of(input);
+      TSDataType actual = expressionTypes.get(inputRef);
+      if (actual == null) {
+        if (expressionTypes.containsKey(inputRef)) {
+          return true;
+        }
+        throw new IllegalStateException(
+            String.format("The type of input expression %s is unknown", 
input));
+      }
+      for (TSDataType type : expected) {
+        if (actual.equals(type)) {
+          return true;
+        }
+      }
+      return false;
+    }
   }
 
   private TSDataType getInputExpressionTypeForAggregation(
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/visitor/ColumnTransformerVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/visitor/ColumnTransformerVisitor.java
index 4c15193fd5f..9bdee1e4788 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/visitor/ColumnTransformerVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/visitor/ColumnTransformerVisitor.java
@@ -54,6 +54,8 @@ import 
org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareL
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.binary.CompareNonEqualColumnTransformer;
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.binary.LogicAndColumnTransformer;
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.binary.LogicOrColumnTransformer;
+import 
org.apache.iotdb.db.queryengine.transformation.dag.column.binary.LongDivisionLongColumnTransformer;
+import 
org.apache.iotdb.db.queryengine.transformation.dag.column.binary.LongModulusLongColumnTransformer;
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.ConstantColumnTransformer;
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.IdentityColumnTransformer;
 import 
org.apache.iotdb.db.queryengine.transformation.dag.column.leaf.LeafColumnTransformer;
@@ -84,6 +86,7 @@ import java.util.stream.Collectors;
 
 import static 
org.apache.iotdb.db.queryengine.plan.expression.ExpressionType.BETWEEN;
 import static org.apache.tsfile.enums.TSDataType.UNKNOWN;
+import static org.apache.tsfile.read.common.type.LongType.INT64;
 
 /** Responsible for constructing {@link ColumnTransformer} through Expression. 
*/
 public class ColumnTransformerVisitor
@@ -474,9 +477,17 @@ public class ColumnTransformerVisitor
         return new ArithmeticMultiplicationColumnTransformer(
             returnType, leftColumnTransformer, rightColumnTransformer);
       case DIVISION:
+        if (returnType == INT64) {
+          return new LongDivisionLongColumnTransformer(
+              returnType, leftColumnTransformer, rightColumnTransformer);
+        }
         return new ArithmeticDivisionColumnTransformer(
             returnType, leftColumnTransformer, rightColumnTransformer);
       case MODULO:
+        if (returnType == INT64) {
+          return new LongModulusLongColumnTransformer(
+              returnType, leftColumnTransformer, rightColumnTransformer);
+        }
         return new ArithmeticModuloColumnTransformer(
             returnType, leftColumnTransformer, rightColumnTransformer);
       case EQUAL_TO:
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeTest.java
index cc2610202cc..542a3db907d 100644
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeTest.java
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeTest.java
@@ -176,9 +176,9 @@ public class AnalyzeTest {
           new DatasetHeader(
               Arrays.asList(
                   new ColumnHeader("root.sg.d1.s1", TSDataType.INT32, null),
-                  new ColumnHeader("root.sg.d1.s1 / 2", TSDataType.DOUBLE, 
null),
+                  new ColumnHeader("root.sg.d1.s1 / 2", TSDataType.INT64, 
null),
                   new ColumnHeader("root.sg.d1.s1 * 3", TSDataType.DOUBLE, 
null),
-                  new ColumnHeader("root.sg.d1.s1 % 4", TSDataType.DOUBLE, 
null),
+                  new ColumnHeader("root.sg.d1.s1 % 4", TSDataType.INT64, 
null),
                   new ColumnHeader("root.sg.d1.s1 - 5", TSDataType.DOUBLE, 
null)),
               false));
       alignByTimeAnalysisEqualTest(actualAnalysis, expectedAnalysis);

Reply via email to