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

Wei-hao-Li pushed a commit to branch fixSemantic
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 831912971415db81234e2decff33ebbb45fae2f5
Author: Weihao Li <[email protected]>
AuthorDate: Wed Dec 2 00:27:51 2026 +0800

    fix in msg
    
    Signed-off-by: Weihao Li <[email protected]>
---
 .../it/db/it/IoTDBCaseWhenThenTableIT.java         | 14 ++++++++
 .../it/query/old/query/IoTDBInTableIT.java         | 37 ++++++++++++++++++++++
 .../org/apache/iotdb/calc/i18n/CalcMessages.java   |  2 ++
 .../org/apache/iotdb/calc/i18n/CalcMessages.java   |  2 ++
 .../relational/ColumnTransformerBuilder.java       | 28 ++++++++++++++--
 .../iotdb/db/i18n/DataNodeQueryMessages.java       |  1 +
 .../iotdb/db/i18n/DataNodeQueryMessages.java       |  1 +
 .../relational/analyzer/ExpressionAnalyzer.java    | 13 +-------
 .../plan/relational/planner/IrTypeAnalyzer.java    |  8 ++---
 .../plan/relational/sql/ast/BinaryLiteral.java     |  5 +++
 .../plan/relational/sql/ast/BooleanLiteral.java    |  5 +++
 .../plan/relational/sql/ast/DecimalLiteral.java    |  5 +++
 .../plan/relational/sql/ast/DoubleLiteral.java     |  5 +++
 .../plan/relational/sql/ast/FloatLiteral.java      |  5 +++
 .../plan/relational/sql/ast/GenericLiteral.java    |  5 +++
 .../plan/relational/sql/ast/Literal.java           |  5 +++
 .../plan/relational/sql/ast/LongLiteral.java       |  5 +++
 .../plan/relational/sql/ast/NullLiteral.java       |  5 +++
 .../plan/relational/sql/ast/StringLiteral.java     |  5 +++
 .../relational/sql/ast/TimeDurationLiteral.java    |  5 +++
 20 files changed, 142 insertions(+), 19 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBCaseWhenThenTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBCaseWhenThenTableIT.java
index 50053867636..0fe40daaf72 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBCaseWhenThenTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBCaseWhenThenTableIT.java
@@ -98,6 +98,20 @@ public class IoTDBCaseWhenThenTableIT {
         DATABASE);
   }
 
+  @Test
+  public void testNullIfNotSupported() {
+    // Originally reported: NULLIF(CAST(status AS STRING), CAST('normal' AS 
STRING)) fails with
+    // "301: Unsupported expression". It is unsupported, so report a clear 
semantic error during
+    // analysis instead of an execution-time failure.
+    String msg = "701: NULLIF is not supported yet.";
+    tableAssertTestFail(
+        "select nullif(cast(s6 as string), cast('text100' as string)) from 
table1", msg, DATABASE);
+    tableAssertTestFail(
+        "select device_id, sum(case when s6 = 'a' then 1 else 0 end) / 
nullif(cast(count(case when s6 = 'a' then 1 end) as double), cast(0 as double)) 
from table1 group by device_id",
+        msg,
+        DATABASE);
+  }
+
   @Test
   public void testKind1Basic() {
     String[] retArray = new String[] {"99,", "9999,", "9999,", "999,"};
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBInTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBInTableIT.java
index c8ffc4c0f47..faf01a795e1 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBInTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBInTableIT.java
@@ -72,6 +72,9 @@ public class IoTDBInTableIT {
         "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v) 
values(1509465900000,'d2','s1','qrcode004', '2024-08-11', 
X'abca',1509465900000)",
         "insert into sg(time,device1,device2,qrcode,date_v,blob_v,timestamp_v) 
values(1509465960000,'d2','s1','qrcode005', '2024-08-12', 
X'abcb',1509465960000)",
         "CREATE TABLE table1(device STRING TAG, s1 INT32 FIELD, s2 INT64 
FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD)",
+        "insert into table1(time, device, s1, s2, s3, s4, s5) values(1, 'd1', 
10, 100, 10.5, 10.5, true)",
+        "insert into table1(time, device, s1, s2, s3, s4, s5) values(2, 'd2', 
20, 200, 20.5, 20.5, false)",
+        "insert into table1(time, device, s1, s2, s3, s4, s5) values(3, 'd3', 
30, 300, 30.5, 30.5, true)",
       };
 
   @BeforeClass
@@ -115,6 +118,40 @@ public class IoTDBInTableIT {
         DATABASE_NAME);
   }
 
+  @Test
+  public void testInExpressionTypeMismatch() {
+    // In expression context (not pushed down into the table scan filter) the 
IN transformer
+    // casts every list item to the column type. Items of a different literal 
kind cannot be
+    // converted there and must be reported as a semantic error instead of a 
raw
+    // ClassCastException. Shapes follow the originally reported failures:
+    //   CASE WHEN temperature = 18 OR temperature = 27 THEN ... (normalized 
to IN (18, 27))
+    //   COUNT(DISTINCT CASE WHEN temperature = 18 OR temperature = 27 THEN 
...)
+    //   SUM(CASE WHEN temperature = 21 OR temperature = 30 THEN ...)
+    String msg =
+        TSStatusCode.SEMANTIC_ERROR.getStatusCode()
+            + ": IN value and list items must be the same type";
+    tableAssertTestFail(
+        "select case when s3 = 18 or s3 = 27 then 1 else 0 end from table1", 
msg, DATABASE_NAME);
+    tableAssertTestFail(
+        "select case when s3 in (18, 27) then 1 else 0 end from table1", msg, 
DATABASE_NAME);
+    tableAssertTestFail(
+        "select count(device), sum(case when s4 = 21 or s4 = 30 then 1 else 0 
end) from table1 group by device",
+        msg,
+        DATABASE_NAME);
+    tableAssertTestFail(
+        "select s3 in (18, 27) from table1", msg, DATABASE_NAME);
+    tableAssertTestFail(
+        "select s3 in (18, 27.5) from table1", msg, DATABASE_NAME);
+    tableAssertTestFail(
+        "select case when s2 in (1.5, 2.5) then 1 else 0 end from table1", 
msg, DATABASE_NAME);
+    // Pushed down as a table scan filter, the items are converted by column 
type. Unchanged.
+    tableResultSetEqualTest(
+        "select count(*) from table1 where s3 in (18, 27)",
+        new String[] {"_col0"},
+        new String[] {"0,"},
+        DATABASE_NAME);
+  }
+
   @Test
   public void selectWithAlignByDeviceTest() {
     String[] retArray =
diff --git 
a/iotdb-core/calc-commons/src/main/i18n/en/org/apache/iotdb/calc/i18n/CalcMessages.java
 
b/iotdb-core/calc-commons/src/main/i18n/en/org/apache/iotdb/calc/i18n/CalcMessages.java
index df1b628f47a..69a06b643a2 100644
--- 
a/iotdb-core/calc-commons/src/main/i18n/en/org/apache/iotdb/calc/i18n/CalcMessages.java
+++ 
b/iotdb-core/calc-commons/src/main/i18n/en/org/apache/iotdb/calc/i18n/CalcMessages.java
@@ -76,6 +76,8 @@ public final class CalcMessages {
       "InputRowUtils should not be instantiated.";
   public static final String IN_LIST_LITERAL_FOR_TIMESTAMP_TYPE_RESTRICTION =
       "InList Literal for TIMESTAMP can only be LongLiteral, DoubleLiteral and 
GenericLiteral, current is %s";
+  public static final String IN_VALUE_AND_LIST_ITEMS_MUST_BE_THE_SAME_TYPE =
+      "IN value and list items must be the same type: %s vs %s";
   public static final String INVALID_AGGREGATION_FUNCTION = "Invalid 
Aggregation function: ";
   public static final String INVALID_TEXT_INPUT_FOR_BOOLEAN =
       "Invalid text input for boolean type: %s";
diff --git 
a/iotdb-core/calc-commons/src/main/i18n/zh/org/apache/iotdb/calc/i18n/CalcMessages.java
 
b/iotdb-core/calc-commons/src/main/i18n/zh/org/apache/iotdb/calc/i18n/CalcMessages.java
index 49b48f6a2d6..edfbd908ed9 100644
--- 
a/iotdb-core/calc-commons/src/main/i18n/zh/org/apache/iotdb/calc/i18n/CalcMessages.java
+++ 
b/iotdb-core/calc-commons/src/main/i18n/zh/org/apache/iotdb/calc/i18n/CalcMessages.java
@@ -74,6 +74,8 @@ public final class CalcMessages {
       "InputRowUtils 不应被实例化。";
   public static final String IN_LIST_LITERAL_FOR_TIMESTAMP_TYPE_RESTRICTION =
       "TIMESTAMP 的 InList 字面量只能是 LongLiteral、DoubleLiteral 和 
GenericLiteral,当前为 %s";
+  public static final String IN_VALUE_AND_LIST_ITEMS_MUST_BE_THE_SAME_TYPE =
+      "IN 的值和列表项必须为相同类型:%s vs %s";
   public static final String INVALID_AGGREGATION_FUNCTION = "无效的聚合函数:";
   public static final String INVALID_TEXT_INPUT_FOR_BOOLEAN =
       "布尔类型的文本输入无效:%s";
diff --git 
a/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
 
b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
index 3b075b6196b..2dd74a5b785 100644
--- 
a/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
+++ 
b/iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/relational/ColumnTransformerBuilder.java
@@ -1526,9 +1526,31 @@ public class ColumnTransformerBuilder
 
   private static InMultiColumnTransformer constructInColumnTransformer(
       Type childType, List<ColumnTransformer> valueColumnTransformerList, 
List<Literal> values) {
-    return TypeServices.IN_MULTI_COLUMN_TRANSFORMER_SERVICE
-        .call(childType)
-        .create(valueColumnTransformerList, values);
+    try {
+      return TypeServices.IN_MULTI_COLUMN_TRANSFORMER_SERVICE
+          .call(childType)
+          .create(valueColumnTransformerList, values);
+    } catch (ClassCastException e) {
+      // The IN transformers cast each literal to the value column's type; a 
literal of an
+      // incompatible kind surfaces here as a raw ClassCastException. Report 
the offending
+      // types instead of leaking the cast failure.
+      throw new SemanticException(
+          String.format(
+              CalcMessages.IN_VALUE_AND_LIST_ITEMS_MUST_BE_THE_SAME_TYPE,
+              childType,
+              describeLiteralTypes(values)));
+    }
+  }
+
+  private static String describeLiteralTypes(List<Literal> values) {
+    StringBuilder builder = new StringBuilder();
+    for (Literal value : values) {
+      if (builder.length() > 0) {
+        builder.append(',');
+      }
+      builder.append(value.getLiteralTypeName());
+    }
+    return builder.toString();
   }
 
   @Override
diff --git 
a/iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
 
b/iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
index 149e2a90460..e535b0da0dc 100644
--- 
a/iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
+++ 
b/iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
@@ -830,6 +830,7 @@ public final class DataNodeQueryMessages {
       "Unknown sign: ";
   public static final String DECIMALLITERAL_IS_NOT_SUPPORTED_YET =
       "DecimalLiteral is not supported yet.";
+  public static final String NULLIF_IS_NOT_SUPPORTED_YET = "NULLIF is not 
supported yet.";
   public static final String GENERICLITERAL_IS_NOT_SUPPORTED_YET =
       "GenericLiteral is not supported yet.";
   public static final String 
DISTINCT_IS_NOT_SUPPORTED_FOR_NON_AGGREGATION_FUNCTIONS =
diff --git 
a/iotdb-core/datanode/src/main/i18n/zh/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
 
b/iotdb-core/datanode/src/main/i18n/zh/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
index efedcfb81ed..9c22d2f10d3 100644
--- 
a/iotdb-core/datanode/src/main/i18n/zh/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
+++ 
b/iotdb-core/datanode/src/main/i18n/zh/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java
@@ -810,6 +810,7 @@ public final class DataNodeQueryMessages {
       "未知的符号:";
   public static final String DECIMALLITERAL_IS_NOT_SUPPORTED_YET =
       "暂不支持 DecimalLiteral。";
+  public static final String NULLIF_IS_NOT_SUPPORTED_YET = "暂不支持 NULLIF 函数。";
   public static final String GENERICLITERAL_IS_NOT_SUPPORTED_YET =
       "暂不支持 GenericLiteral。";
   public static final String 
DISTINCT_IS_NOT_SUPPORTED_FOR_NON_AGGREGATION_FUNCTIONS =
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
index 10733e34975..7bd2f761c99 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
@@ -787,18 +787,7 @@ public class ExpressionAnalyzer {
     @Override
     public Type visitNullIfExpression(
         NullIfExpression node, StackableAstVisitorContext<Context> context) {
-      Type firstType = process(node.getFirst(), context);
-      Type secondType = process(node.getSecond(), context);
-
-      if (!firstType.equals(secondType)) {
-        throw new SemanticException(
-            String.format(
-                
DataNodeQueryMessages.TYPES_ARE_NOT_COMPARABLE_WITH_NULLIF_S_VS_S,
-                firstType,
-                secondType));
-      }
-
-      return setExpressionType(node, firstType);
+      throw new 
SemanticException(DataNodeQueryMessages.NULLIF_IS_NOT_SUPPORTED_YET);
     }
 
     @Override
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/IrTypeAnalyzer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/IrTypeAnalyzer.java
index 300d1b0a0a1..f3113b74f33 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/IrTypeAnalyzer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/IrTypeAnalyzer.java
@@ -538,7 +538,7 @@ public class IrTypeAnalyzer {
     private void coerceType(
         Context context, Expression expression, Type expectedType, 
Function<Type, String> message) {
       Type actualType = process(expression, context);
-      coerceType(expression, expectedType, actualType, message);
+      coerceType(expression, actualType, expectedType, message);
     }
 
     private Type coerceToSingleType(
@@ -560,9 +560,9 @@ public class IrTypeAnalyzer {
         if (TypeCoercionUtils.canCoerceTo(current, superType)) {
           continue;
         }
-        if (TypeCoercionUtils.canCoerceTo(superType, current)) {
-          superType = current;
-        }
+        // Report the pair being compared as-is: superType must not be 
overwritten before the
+        // message is built, otherwise an INT32-widenable pair such as (INT32, 
INT64) is reported
+        // as "INT64 vs INT64".
         throw new SemanticException(
             String.format(description + DataNodeQueryMessages.COLON_S_VS_S, 
superType, current));
       }
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BinaryLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BinaryLiteral.java
index 38c6c4284b7..15d5ab55b4a 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BinaryLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BinaryLiteral.java
@@ -148,6 +148,11 @@ public class BinaryLiteral extends Literal {
     return new Binary(value);
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "BLOB";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BooleanLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BooleanLiteral.java
index 6d9a9cc9a66..a2de71e8cd3 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BooleanLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/BooleanLiteral.java
@@ -116,6 +116,11 @@ public class BooleanLiteral extends Literal {
     return value;
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "BOOLEAN";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DecimalLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DecimalLiteral.java
index 0842b68e393..fe28bc388e8 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DecimalLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DecimalLiteral.java
@@ -107,6 +107,11 @@ public class DecimalLiteral extends Literal {
     return new Binary(value.getBytes(StandardCharsets.UTF_8));
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "DECIMAL";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DoubleLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DoubleLiteral.java
index 3584dde5d02..2fa59235728 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DoubleLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/DoubleLiteral.java
@@ -117,6 +117,11 @@ public class DoubleLiteral extends Literal {
     return value;
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "DOUBLE";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/FloatLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/FloatLiteral.java
index dc8c80abf11..54e5529c239 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/FloatLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/FloatLiteral.java
@@ -111,6 +111,11 @@ public class FloatLiteral extends Literal {
     return value;
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "FLOAT";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/GenericLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/GenericLiteral.java
index 87df4eabab3..7fd5bc11088 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/GenericLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/GenericLiteral.java
@@ -132,6 +132,11 @@ public class GenericLiteral extends Literal {
     return new Binary(value.getBytes(StandardCharsets.UTF_8));
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return type;
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/Literal.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/Literal.java
index 5f11f326fb8..a2470b082b9 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/Literal.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/Literal.java
@@ -44,4 +44,9 @@ public abstract class Literal extends Expression {
    * @return a value that can be processed by IoTDB storage engine
    */
   public abstract Object getTsValue();
+
+  /**
+   * @return the SQL type name of this literal, e.g. INT32, INT64, DOUBLE, 
used in error messages
+   */
+  public abstract String getLiteralTypeName();
 }
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/LongLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/LongLiteral.java
index 694e7af0019..1ee221a681d 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/LongLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/LongLiteral.java
@@ -141,6 +141,11 @@ public class LongLiteral extends Literal {
     return parsedValue;
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return parsedValue >= Integer.MIN_VALUE && parsedValue <= 
Integer.MAX_VALUE ? "INT32" : "INT64";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/NullLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/NullLiteral.java
index d111def6af6..cde8795e6c8 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/NullLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/NullLiteral.java
@@ -86,6 +86,11 @@ public class NullLiteral extends Literal {
     return null;
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "UNKNOWN";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/StringLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/StringLiteral.java
index 63096646232..0812c9cfc98 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/StringLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/StringLiteral.java
@@ -116,6 +116,11 @@ public class StringLiteral extends Literal {
     return new Binary(value.getBytes(StandardCharsets.UTF_8));
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "STRING";
+  }
+
   @Override
   public long ramBytesUsed() {
     return INSTANCE_SIZE
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/TimeDurationLiteral.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/TimeDurationLiteral.java
index 8ceb5e9bad7..8b2a31b2c8b 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/TimeDurationLiteral.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/queryengine/plan/relational/sql/ast/TimeDurationLiteral.java
@@ -62,6 +62,11 @@ public class TimeDurationLiteral extends Literal {
     return value;
   }
 
+  @Override
+  public String getLiteralTypeName() {
+    return "INTERVAL";
+  }
+
   @Override
   public int hashCode() {
     return Objects.hash(value);

Reply via email to