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

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


The following commit(s) were added to refs/heads/master by this push:
     new 15365ffe363 Allow duplicated column names in table model
15365ffe363 is described below

commit 15365ffe363316161e0c120abca5780f539a2a8e
Author: Jackie Tien <[email protected]>
AuthorDate: Tue Sep 10 09:11:31 2024 +0800

    Allow duplicated column names in table model
---
 data.zip                                           | Bin 0 -> 101329 bytes
 .../org/apache/iotdb/db/it/IoTDBRecoverIT.java     |  40 +-
 .../apache/iotdb/db/it/IoTDBRecoverUnclosedIT.java |  29 +-
 .../db/it/aggregation/IoTDBAggregationIT.java      | 237 ++++-------
 .../aggregation/IoTDBAggregationLargeDataIT.java   | 133 ++-----
 .../aggregation/IoTDBAggregationSmallDataIT.java   | 113 ++----
 .../it/schema/IoTDBDeleteAlignedTimeseriesIT.java  |   8 +-
 .../db/it/schema/IoTDBDeleteTimeSeriesIT.java      |  52 ++-
 .../iotdb/db/it/udaf/IoTDBUDAFNormalQueryIT.java   |  44 +-
 .../iotdb/db/it/udf/IoTDBUDTFHybridQueryIT.java    |   6 +-
 .../it/query/recent/IoTDBNullIdQueryIT.java        |  20 +
 .../java/org/apache/iotdb/cli/AbstractCli.java     |   2 +-
 .../org/apache/iotdb/isession/SessionDataSet.java  |  34 +-
 .../org/apache/iotdb/jdbc/IoTDBJDBCResultSet.java  |  42 +-
 .../java/org/apache/iotdb/jdbc/IoTDBStatement.java |   6 +-
 .../iotdb/jdbc/IoTDBDatabaseMetadataTest.java      |   6 +-
 .../apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java  |   9 +
 .../java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java | 443 ++++++++++++---------
 .../apache/iotdb/session/SessionConnection.java    |  15 +-
 .../org/apache/iotdb/session/ThriftConnection.java |   3 +-
 .../apache/iotdb/session/pool/SessionPoolTest.java |  10 +-
 .../protocol/thrift/impl/ClientRPCServiceImpl.java |   3 +-
 .../queryengine/common/header/DatasetHeader.java   |  37 +-
 .../planner/distribution/DistributionPlanner.java  |   2 +-
 .../thrift-datanode/src/main/thrift/client.thrift  |   1 +
 25 files changed, 609 insertions(+), 686 deletions(-)

diff --git a/data.zip b/data.zip
new file mode 100644
index 00000000000..331d31fd2dc
Binary files /dev/null and b/data.zip differ
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverIT.java 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverIT.java
index 41bcc24a375..757b514ff13 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverIT.java
@@ -52,7 +52,6 @@ public class IoTDBRecoverIT {
 
   private static final Logger logger = 
LoggerFactory.getLogger(IoTDBRecoverIT.class);
 
-  private static final String TIMESTAMP_STR = "Time";
   private static final String TEMPERATURE_STR = 
"root.ln.wf01.wt01.temperature";
   private static final String[] creationSqls =
       new String[] {
@@ -110,7 +109,7 @@ public class IoTDBRecoverIT {
     logger.info("All DataNodes are started");
     // check cluster whether restart
     ((AbstractEnv) EnvFactory.getEnv()).checkClusterStatusWithoutUnknown();
-    String[] retArray = new String[] {"0,2", "0,4", "0,3"};
+    String[] retArray = new String[] {"2", "4", "3"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -118,8 +117,7 @@ public class IoTDBRecoverIT {
       try (ResultSet resultSet = statement.executeQuery(selectSql)) {
         assertNotNull(resultSet);
         resultSet.next();
-        String ans =
-            resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(count(TEMPERATURE_STR));
+        String ans = resultSet.getString(count(TEMPERATURE_STR));
         Assert.assertEquals(retArray[0], ans);
       }
 
@@ -127,10 +125,7 @@ public class IoTDBRecoverIT {
       try (ResultSet resultSet = statement.executeQuery(selectSql)) {
         assertNotNull(resultSet);
         resultSet.next();
-        String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(minTime(TEMPERATURE_STR));
+        String ans = resultSet.getString(minTime(TEMPERATURE_STR));
         Assert.assertEquals(retArray[1], ans);
       }
 
@@ -138,10 +133,7 @@ public class IoTDBRecoverIT {
       try (ResultSet resultSet = statement.executeQuery(selectSql)) {
         assertNotNull(resultSet);
         resultSet.next();
-        String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(minTime(TEMPERATURE_STR));
+        String ans = resultSet.getString(minTime(TEMPERATURE_STR));
         Assert.assertEquals(retArray[2], ans);
       }
 
@@ -151,7 +143,7 @@ public class IoTDBRecoverIT {
     }
 
     // max min ValueTest
-    retArray = new String[] {"0,8499,500.0", "0,2499,500.0"};
+    retArray = new String[] {"8499,500.0", "2499,500.0"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -162,11 +154,7 @@ public class IoTDBRecoverIT {
         assertNotNull(resultSet);
         resultSet.next();
         String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(maxValue(d0s0))
-                + ","
-                + resultSet.getString(minValue(d0s2));
+            resultSet.getString(maxValue(d0s0)) + "," + 
resultSet.getString(minValue(d0s2));
         Assert.assertEquals(retArray[0], ans);
       }
 
@@ -175,11 +163,7 @@ public class IoTDBRecoverIT {
         assertNotNull(resultSet);
         resultSet.next();
         String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(maxValue(d0s0))
-                + ","
-                + resultSet.getString(minValue(d0s2));
+            resultSet.getString(maxValue(d0s0)) + "," + 
resultSet.getString(minValue(d0s2));
         Assert.assertEquals(retArray[1], ans);
       }
     } catch (Exception e) {
@@ -202,7 +186,7 @@ public class IoTDBRecoverIT {
     // wait for cluster to start and check
     ((AbstractEnv) EnvFactory.getEnv()).checkClusterStatusWithoutUnknown();
     // count test
-    String[] retArray = new String[] {"0,2001,2001,2001,2001", 
"0,7500,7500,7500,7500"};
+    String[] retArray = new String[] {"2001,2001,2001,2001", 
"7500,7500,7500,7500"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -213,9 +197,7 @@ public class IoTDBRecoverIT {
         assertNotNull(resultSet);
         resultSet.next();
         String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(count(d0s0))
+            resultSet.getString(count(d0s0))
                 + ","
                 + resultSet.getString(count(d0s1))
                 + ","
@@ -230,9 +212,7 @@ public class IoTDBRecoverIT {
         assertNotNull(resultSet);
         resultSet.next();
         String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(count(d0s0))
+            resultSet.getString(count(d0s0))
                 + ","
                 + resultSet.getString(count(d0s1))
                 + ","
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverUnclosedIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverUnclosedIT.java
index 01a3c791876..6ea26e7bc70 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverUnclosedIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRecoverUnclosedIT.java
@@ -96,7 +96,7 @@ public class IoTDBRecoverUnclosedIT {
 
   @Test
   public void test() throws SQLException, IOException {
-    String[] retArray = new String[] {"0,2", "0,4", "0,3"};
+    String[] retArray = new String[] {"2", "4", "3"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -104,8 +104,7 @@ public class IoTDBRecoverUnclosedIT {
       try (ResultSet resultSet = statement.executeQuery(selectSql)) {
         assertNotNull(resultSet);
         resultSet.next();
-        String ans =
-            resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(count(TEMPERATURE_STR));
+        String ans = resultSet.getString(count(TEMPERATURE_STR));
         assertEquals(retArray[0], ans);
       }
 
@@ -113,10 +112,7 @@ public class IoTDBRecoverUnclosedIT {
       try (ResultSet resultSet = statement.executeQuery(selectSql)) {
         assertNotNull(resultSet);
         resultSet.next();
-        String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(minTime(TEMPERATURE_STR));
+        String ans = resultSet.getString(minTime(TEMPERATURE_STR));
         assertEquals(retArray[1], ans);
       }
 
@@ -124,10 +120,7 @@ public class IoTDBRecoverUnclosedIT {
       try (ResultSet resultSet = statement.executeQuery(selectSql)) {
         assertNotNull(resultSet);
         resultSet.next();
-        String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(minTime(TEMPERATURE_STR));
+        String ans = resultSet.getString(minTime(TEMPERATURE_STR));
         assertEquals(retArray[2], ans);
       }
 
@@ -163,7 +156,7 @@ public class IoTDBRecoverUnclosedIT {
       assertEquals(7500, tempResultSet.getInt("count(" + d0s0 + ")"));
 
       // test max, min value
-      retArray = new String[] {"0,8499,500.0", "0,2499,500.0"};
+      retArray = new String[] {"8499,500.0", "2499,500.0"};
       selectSql =
           "select max_value(s0),min_value(s2) "
               + "from root.vehicle.d0 where time >= 100 and time < 9000";
@@ -171,11 +164,7 @@ public class IoTDBRecoverUnclosedIT {
         assertNotNull(resultSet);
         resultSet.next();
         String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(maxValue(d0s0))
-                + ","
-                + resultSet.getString(minValue(d0s2));
+            resultSet.getString(maxValue(d0s0)) + "," + 
resultSet.getString(minValue(d0s2));
         assertEquals(retArray[0], ans);
       }
 
@@ -184,11 +173,7 @@ public class IoTDBRecoverUnclosedIT {
         assertNotNull(resultSet);
         resultSet.next();
         String ans =
-            resultSet.getString(TIMESTAMP_STR)
-                + ","
-                + resultSet.getString(maxValue(d0s1))
-                + ","
-                + resultSet.getString(minValue(d0s2));
+            resultSet.getString(maxValue(d0s1)) + "," + 
resultSet.getString(minValue(d0s2));
         assertEquals(retArray[1], ans);
       }
     } catch (Exception e) {
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationIT.java
index bb2b1d539bf..524d0770a6c 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationIT.java
@@ -59,7 +59,6 @@ import static org.junit.Assert.fail;
 public class IoTDBAggregationIT {
 
   private static final double DETLA = 1e-6;
-  private static final String TIMESTAMP_STR = "Time";
   private static final String TEMPERATURE_STR = 
"root.ln.wf01.wt01.temperature";
 
   private static final String[] creationSqls =
@@ -135,7 +134,7 @@ public class IoTDBAggregationIT {
   // details in: https://issues.apache.org/jira/projects/IOTDB/issues/IOTDB-54
   @Test
   public void test() {
-    String[] retArray = new String[] {"0,2", "0,4", "0,3"};
+    String[] retArray = new String[] {"2", "4", "3"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -145,10 +144,7 @@ public class IoTDBAggregationIT {
               "SELECT count(temperature) FROM root.ln.wf01.wt01 WHERE time > 
3")) {
         cnt = 0;
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(TEMPERATURE_STR));
+          String ans = resultSet.getString(count(TEMPERATURE_STR));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -160,10 +156,7 @@ public class IoTDBAggregationIT {
               "SELECT count(temperature) FROM root.ln.wf01.wt01 WHERE time > 3 
order by time desc")) {
         cnt = 0;
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(TEMPERATURE_STR));
+          String ans = resultSet.getString(count(TEMPERATURE_STR));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -174,10 +167,7 @@ public class IoTDBAggregationIT {
           statement.executeQuery(
               "SELECT min_time(temperature) FROM root.ln.wf01.wt01 WHERE time 
> 3")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minTime(TEMPERATURE_STR));
+          String ans = resultSet.getString(minTime(TEMPERATURE_STR));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -188,10 +178,7 @@ public class IoTDBAggregationIT {
           statement.executeQuery(
               "SELECT min_time(temperature) FROM root.ln.wf01.wt01 WHERE 
temperature > 3")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minTime(TEMPERATURE_STR));
+          String ans = resultSet.getString(minTime(TEMPERATURE_STR));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -213,7 +200,7 @@ public class IoTDBAggregationIT {
   public void countTest() {
     String[] retArray =
         new String[] {
-          "0,2001,2001,2001,2001,2001,2001,2001,2001", 
"0,7500,7500,7500,7500,7500,7500,7500,7500"
+          "2001,2001,2001,2001,2001,2001,2001,2001", 
"7500,7500,7500,7500,7500,7500,7500,7500"
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -226,9 +213,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -256,9 +241,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -287,9 +270,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -316,9 +297,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -348,8 +327,8 @@ public class IoTDBAggregationIT {
   public void firstTest() {
     String[] retArray =
         new String[] {
-          
"0,2000,2000,2000.0,2000,2000,0x2000,2000-01-01,1970-01-01T00:00:02.000Z",
-          "0,500,500,500.0,500,500,0x0500,1500-01-01,1970-01-01T00:00:00.500Z"
+          
"2000,2000,2000.0,2000,2000,0x2000,2000-01-01,1970-01-01T00:00:02.000Z",
+          "500,500,500.0,500,500,0x0500,1500-01-01,1970-01-01T00:00:00.500Z"
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -361,9 +340,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -390,9 +367,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -421,9 +396,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -453,9 +426,9 @@ public class IoTDBAggregationIT {
   public void lastTest() {
     String[] retArray =
         new String[] {
-          "0,8499,8499.0,8499,0x8499,8499-01-01,1970-01-01T00:00:08.499Z",
-          "0,1499,1499.0,1499,0x1499,1499-01-01,1970-01-01T00:00:01.499Z",
-          "0,2200,2200.0,2200,0x2200,2200-01-01,1970-01-01T00:00:02.200Z"
+          "8499,8499.0,8499,0x8499,8499-01-01,1970-01-01T00:00:08.499Z",
+          "1499,1499.0,1499,0x1499,1499-01-01,1970-01-01T00:00:01.499Z",
+          "2200,2200.0,2200,0x2200,2200-01-01,1970-01-01T00:00:02.200Z"
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -468,9 +441,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s2))
                   + ","
@@ -493,9 +464,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 WHERE time <= 1600")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s2))
                   + ","
@@ -518,9 +487,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 WHERE time <= 2200")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s2))
                   + ","
@@ -544,9 +511,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s2))
                   + ","
@@ -571,9 +536,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s2))
                   + ","
@@ -597,8 +560,7 @@ public class IoTDBAggregationIT {
 
   @Test
   public void maxminTimeTest() {
-    String[] retArray =
-        new String[] {"0,8499,500,8499,500,8499,500,8499,500,8499,500", 
"0,2499,2000"};
+    String[] retArray = new String[] 
{"8499,500,8499,500,8499,500,8499,500,8499,500", "2499,2000"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -610,9 +572,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime(d0s0))
+              resultSet.getString(maxTime(d0s0))
                   + ","
                   + resultSet.getString(minTime(d0s2))
                   + ","
@@ -643,11 +603,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 WHERE time <= 2500 AND time > 
1800")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime(d0s0))
-                  + ","
-                  + resultSet.getString(minTime(d0s2));
+              resultSet.getString(maxTime(d0s0)) + "," + 
resultSet.getString(minTime(d0s2));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -662,9 +618,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime(d0s0))
+              resultSet.getString(maxTime(d0s0))
                   + ","
                   + resultSet.getString(minTime(d0s2))
                   + ","
@@ -698,7 +652,7 @@ public class IoTDBAggregationIT {
   public void firstLastValueTest() throws SQLException {
     String[] retArray =
         new String[] {
-          "0,2.2,4.4",
+          "2.2,4.4",
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -710,12 +664,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.ln.wf01.wt01 WHERE time > 1 AND time < 5")) {
         cnt = 0;
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(1)
-                  + ","
-                  + resultSet.getString(2);
+          String ans = resultSet.getString(1) + "," + resultSet.getString(2);
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -728,8 +677,8 @@ public class IoTDBAggregationIT {
   public void maxminValueTest() {
     String[] retArray =
         new String[] {
-          
"0,8499,500.0,999,1000,8499-01-01,1000-01-01,1970-01-01T00:00:08.499Z,1970-01-01T00:00:00.500Z",
-          "0,2499,500.0"
+          
"8499,500.0,999,1000,8499-01-01,1000-01-01,1970-01-01T00:00:08.499Z,1970-01-01T00:00:00.500Z",
+          "2499,500.0"
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -742,9 +691,7 @@ public class IoTDBAggregationIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
+              resultSet.getString(maxValue(d0s0))
                   + ","
                   + resultSet.getString(minValue(d0s2))
                   + ","
@@ -770,11 +717,7 @@ public class IoTDBAggregationIT {
               "SELECT max_value(s0),min_value(s2) " + "FROM root.vehicle.d0 
WHERE time < 2500")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
-                  + ","
-                  + resultSet.getString(minValue(d0s2));
+              resultSet.getString(maxValue(d0s0)) + "," + 
resultSet.getString(minValue(d0s2));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -789,9 +732,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000 
order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
+              resultSet.getString(maxValue(d0s0))
                   + ","
                   + resultSet.getString(minValue(d0s2))
                   + ","
@@ -820,8 +761,8 @@ public class IoTDBAggregationIT {
   @Test
   public void avgSumTest() {
     double[][] retArray = {
-      {0.0, 1.4508E7, 7250.374812593702},
-      {0.0, 626750.0, 1250.9980039920158}
+      {1.4508E7, 7250.374812593702},
+      {626750.0, 1250.9980039920158}
     };
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -833,10 +774,9 @@ public class IoTDBAggregationIT {
               "SELECT sum(s0),avg(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 
9000")) {
         while (resultSet.next()) {
-          double[] ans = new double[3];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          double[] ans = new double[2];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -848,10 +788,9 @@ public class IoTDBAggregationIT {
               "SELECT sum(s0),avg(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 1000 AND time <= 
2000")) {
         while (resultSet.next()) {
-          double[] ans = new double[3];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          double[] ans = new double[2];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -865,10 +804,9 @@ public class IoTDBAggregationIT {
               "SELECT sum(s0),avg(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000 
order by time desc")) {
         while (resultSet.next()) {
-          double[] ans = new double[3];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          double[] ans = new double[2];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -946,10 +884,10 @@ public class IoTDBAggregationIT {
   @Test
   public void mergeAggrOnOneSeriesTest() {
     double[][] retArray = {
-      {0.0, 1.4508E7, 7250.374812593702, 7250.374812593702, 1.4508E7},
-      {0.0, 626750.0, 1250.9980039920158, 1250.9980039920158, 626750.0},
-      {0.0, 1.4508E7, 2001, 7250.374812593702, 7250.374812593702},
-      {0.0, 1.4508E7, 2001, 7250.374812593702, 7250.374812593702, 2001, 
1.4508E7}
+      {1.4508E7, 7250.374812593702, 7250.374812593702, 1.4508E7},
+      {626750.0, 1250.9980039920158, 1250.9980039920158, 626750.0},
+      {1.4508E7, 2001, 7250.374812593702, 7250.374812593702},
+      {1.4508E7, 2001, 7250.374812593702, 7250.374812593702, 2001, 1.4508E7}
     };
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -961,12 +899,11 @@ public class IoTDBAggregationIT {
               "SELECT sum(s0), avg(s2), avg(s0), sum(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 
9000")) {
         while (resultSet.next()) {
-          double[] ans = new double[5];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
-          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s0)));
-          ans[4] = Double.parseDouble(resultSet.getString(sum(d0s2)));
+          double[] ans = new double[4];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s0)));
+          ans[3] = Double.parseDouble(resultSet.getString(sum(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -978,12 +915,11 @@ public class IoTDBAggregationIT {
               "SELECT sum(s0), avg(s2), avg(s0), sum(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 1000 AND time <= 
2000")) {
         while (resultSet.next()) {
-          double[] ans = new double[5];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
-          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s0)));
-          ans[4] = Double.parseDouble(resultSet.getString(sum(d0s2)));
+          double[] ans = new double[4];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s0)));
+          ans[3] = Double.parseDouble(resultSet.getString(sum(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -995,12 +931,11 @@ public class IoTDBAggregationIT {
               "SELECT sum(s0), count(s0), avg(s2), avg(s0)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 
9000")) {
         while (resultSet.next()) {
-          double[] ans = new double[5];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(count(d0s0)));
-          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s2)));
-          ans[4] = Double.parseDouble(resultSet.getString(avg(d0s0)));
+          double[] ans = new double[4];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(count(d0s0)));
+          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s0)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -1012,14 +947,13 @@ public class IoTDBAggregationIT {
               "SELECT sum(s2), count(s0), avg(s2), avg(s1), count(s2),sum(s0)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 
9000")) {
         while (resultSet.next()) {
-          double[] ans = new double[7];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sum(d0s2)));
-          ans[2] = Double.parseDouble(resultSet.getString(count(d0s0)));
-          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s2)));
-          ans[4] = Double.parseDouble(resultSet.getString(avg(d0s1)));
-          ans[5] = Double.parseDouble(resultSet.getString(count(d0s2)));
-          ans[6] = Double.parseDouble(resultSet.getString(sum(d0s0)));
+          double[] ans = new double[6];
+          ans[0] = Double.parseDouble(resultSet.getString(sum(d0s2)));
+          ans[1] = Double.parseDouble(resultSet.getString(count(d0s0)));
+          ans[2] = Double.parseDouble(resultSet.getString(avg(d0s2)));
+          ans[3] = Double.parseDouble(resultSet.getString(avg(d0s1)));
+          ans[4] = Double.parseDouble(resultSet.getString(count(d0s2)));
+          ans[5] = Double.parseDouble(resultSet.getString(sum(d0s0)));
           assertArrayEquals(retArray[cnt], ans, DETLA);
           cnt++;
         }
@@ -1035,7 +969,7 @@ public class IoTDBAggregationIT {
   public void descAggregationWithUnseqData() {
     String[] retArray =
         new String[] {
-          "0,12",
+          "12",
         };
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -1044,10 +978,7 @@ public class IoTDBAggregationIT {
       try (ResultSet resultSet =
           statement.executeQuery("SELECT max_time(s1) FROM root.sg.d1 where 
time < 15")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime("root.sg.d1.s1"));
+          String ans = resultSet.getString(maxTime("root.sg.d1.s1"));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -1233,7 +1164,7 @@ public class IoTDBAggregationIT {
 
   @Test
   public void maxByTest() {
-    String[] retArray = new String[] {"0,8499", "0,2499", "0,8499"};
+    String[] retArray = new String[] {"8499", "2499", "8499"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -1244,8 +1175,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000")) 
{
         cnt = 0;
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(maxBy("Time", d0s0));
+          String ans = resultSet.getString(maxBy("Time", d0s0));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -1255,8 +1185,7 @@ public class IoTDBAggregationIT {
       try (ResultSet resultSet =
           statement.executeQuery("SELECT max_by(time,s0) FROM root.vehicle.d0 
WHERE time < 2500")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(maxBy("Time", d0s0));
+          String ans = resultSet.getString(maxBy("Time", d0s0));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -1269,8 +1198,7 @@ public class IoTDBAggregationIT {
           statement.executeQuery(
               "SELECT max_by(time,s0) FROM root.vehicle.d0 WHERE time >= 100 
AND time < 9000 order by time desc")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(maxBy("Time", d0s0));
+          String ans = resultSet.getString(maxBy("Time", d0s0));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -1284,7 +1212,7 @@ public class IoTDBAggregationIT {
 
   @Test
   public void minByTest() {
-    String[] retArray = new String[] {"0,500", "0,500", "0,500"};
+    String[] retArray = new String[] {"500", "500", "500"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -1295,8 +1223,7 @@ public class IoTDBAggregationIT {
                   + "FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000")) 
{
         cnt = 0;
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(minBy("Time", d0s0));
+          String ans = resultSet.getString(minBy("Time", d0s0));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -1306,8 +1233,7 @@ public class IoTDBAggregationIT {
       try (ResultSet resultSet =
           statement.executeQuery("SELECT min_by(time,s0) FROM root.vehicle.d0 
WHERE time < 2500")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(minBy("Time", d0s0));
+          String ans = resultSet.getString(minBy("Time", d0s0));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -1320,8 +1246,7 @@ public class IoTDBAggregationIT {
           statement.executeQuery(
               "SELECT min_by(time,s0) FROM root.vehicle.d0 WHERE time >= 100 
AND time < 9000 order by time desc")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR) + "," + 
resultSet.getString(minBy("Time", d0s0));
+          String ans = resultSet.getString(minBy("Time", d0s0));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationLargeDataIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationLargeDataIT.java
index 4d24e7284af..743feb996db 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationLargeDataIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationLargeDataIT.java
@@ -51,7 +51,6 @@ import static org.junit.Assert.fail;
 @Category({LocalStandaloneIT.class, ClusterIT.class})
 public class IoTDBAggregationLargeDataIT {
 
-  private static final String TIMESTAMP_STR = "Time";
   private final String d0s0 = "root.vehicle.d0.s0";
   private final String d0s1 = "root.vehicle.d0.s1";
   private final String d0s2 = "root.vehicle.d0.s2";
@@ -127,7 +126,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void lastValueAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,9,39,63.0,E,true"};
+    String[] retArray = new String[] {"9,39,63.0,E,true"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -139,9 +138,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s1))
                   + ","
@@ -163,9 +160,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d0s1))
                   + ","
@@ -187,7 +182,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void sumAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,55061.0,156752.0,20254"};
+    String[] retArray = new String[] {"55061.0,156752.0,20254"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -198,9 +193,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
+              resultSet.getString(sum(d0s0))
                   + ","
                   + resultSet.getString(sum(d0s1))
                   + ","
@@ -218,9 +211,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
+              resultSet.getString(sum(d0s0))
                   + ","
                   + resultSet.getString(sum(d0s1))
                   + ","
@@ -238,7 +229,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void firstAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,90,1101,2.22,ddddd,true"};
+    String[] retArray = new String[] {"90,1101,2.22,ddddd,true"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -250,9 +241,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -275,9 +264,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -299,7 +286,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void avgAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,75,212,28"};
+    String[] retArray = new String[] {"75,212,28"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -309,9 +296,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + Math.round(resultSet.getDouble(avg(d0s0)))
+              Math.round(resultSet.getDouble(avg(d0s0)))
                   + ","
                   + Math.round(resultSet.getDouble(avg(d0s1)))
                   + ","
@@ -328,9 +313,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + Math.round(resultSet.getDouble(avg(d0s0)))
+              Math.round(resultSet.getDouble(avg(d0s0)))
                   + ","
                   + Math.round(resultSet.getDouble(avg(d0s1)))
                   + ","
@@ -348,7 +331,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void countAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,733,740,734"};
+    String[] retArray = new String[] {"733,740,734"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -359,9 +342,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -378,9 +359,7 @@ public class IoTDBAggregationLargeDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -398,7 +377,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void minTimeAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,104,1,2,101,100"};
+    String[] retArray = new String[] {"104,1,2,101,100"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -410,9 +389,7 @@ public class IoTDBAggregationLargeDataIT {
                   + " from root.vehicle.d0 where s1 >= 0")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minTime(d0s0))
+              resultSet.getString(minTime(d0s0))
                   + ","
                   + resultSet.getString(minTime(d0s1))
                   + ","
@@ -435,9 +412,7 @@ public class IoTDBAggregationLargeDataIT {
                   + " from root.vehicle.d0 where s1 >= 0 order by time desc")) 
{
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minTime(d0s0))
+              resultSet.getString(minTime(d0s0))
                   + ","
                   + resultSet.getString(minTime(d0s1))
                   + ","
@@ -459,7 +434,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void minValueAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,0,0,0.0"};
+    String[] retArray = new String[] {"0,0,0.0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -471,9 +446,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minValue(d0s0))
+              resultSet.getString(minValue(d0s0))
                   + ","
                   + resultSet.getString(minValue(d0s1))
                   + ","
@@ -491,9 +464,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minValue(d0s0))
+              resultSet.getString(minValue(d0s0))
                   + ","
                   + resultSet.getString(minValue(d0s1))
                   + ","
@@ -511,7 +482,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void maxValueAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,99,40000,122.0"};
+    String[] retArray = new String[] {"99,40000,122.0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -523,9 +494,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
+              resultSet.getString(maxValue(d0s0))
                   + ","
                   + resultSet.getString(maxValue(d0s1))
                   + ","
@@ -543,9 +512,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
+              resultSet.getString(maxValue(d0s0))
                   + ","
                   + resultSet.getString(maxValue(d0s1))
                   + ","
@@ -563,7 +530,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void extremeAggreWithSingleFilterTest() {
-    String[] retArray = new String[] {"0,99,40000,122.0"};
+    String[] retArray = new String[] {"99,40000,122.0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -576,9 +543,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(extreme(d0s0))
+              resultSet.getString(extreme(d0s0))
                   + ","
                   + resultSet.getString(extreme(d0s1))
                   + ","
@@ -597,9 +562,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(extreme(d0s0))
+              resultSet.getString(extreme(d0s0))
                   + ","
                   + resultSet.getString(extreme(d0s1))
                   + ","
@@ -617,7 +580,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void avgAggreWithMultiFilterTest() {
-    String[] retArray = new String[] {"0,55061.0,733,75,212,28"};
+    String[] retArray = new String[] {"55061.0,733,75,212,28"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -629,9 +592,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "avg(s2) from root.vehicle.d0 where s1 >= 0 or s2 < 10")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
+              resultSet.getString(sum(d0s0))
                   + ","
                   + resultSet.getString(count(d0s0))
                   + ","
@@ -653,7 +614,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void sumAggreWithMultiFilterTest() {
-    String[] retArray = new String[] {"0,55061.0,156752.0,20262"};
+    String[] retArray = new String[] {"55061.0,156752.0,20262"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -664,9 +625,7 @@ public class IoTDBAggregationLargeDataIT {
               "select sum(s0),sum(s1),sum(s2) from root.vehicle.d0 where s1 >= 
0 or s2 < 10")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
+              resultSet.getString(sum(d0s0))
                   + ","
                   + resultSet.getString(sum(d0s1))
                   + ","
@@ -684,9 +643,7 @@ public class IoTDBAggregationLargeDataIT {
                   + " where s1 >= 0 or s2 < 10 order by time desc ")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
+              resultSet.getString(sum(d0s0))
                   + ","
                   + resultSet.getString(sum(d0s1))
                   + ","
@@ -704,7 +661,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void firstAggreWithMultiFilterTest() {
-    String[] retArray = new String[] {"0,90,1101,2.22,ddddd,true"};
+    String[] retArray = new String[] {"90,1101,2.22,ddddd,true"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -716,9 +673,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "first_value(s4) from root.vehicle.d0 where s1 >= 0 or s2 
< 10")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -741,9 +696,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "first_value(s4) from root.vehicle.d0 where s1 >= 0 or s2 
< 10 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d0s1))
                   + ","
@@ -765,7 +718,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void countAggreWithMultiFilterTest() {
-    String[] retArray = new String[] {"0,733,740,736,482,1"};
+    String[] retArray = new String[] {"733,740,736,482,1"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -777,9 +730,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "count(s4) from root.vehicle.d0 where s1 >= 0 or s2 < 
10")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -801,7 +752,7 @@ public class IoTDBAggregationLargeDataIT {
 
   @Test
   public void maxTimeAggreWithMultiFilterTest() {
-    String[] retArray = new String[] {"0,3999,3999,3999,3599,100"};
+    String[] retArray = new String[] {"3999,3999,3999,3599,100"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -814,9 +765,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime(d0s0))
+              resultSet.getString(maxTime(d0s0))
                   + ","
                   + resultSet.getString(maxTime(d0s1))
                   + ","
@@ -839,9 +788,7 @@ public class IoTDBAggregationLargeDataIT {
                   + "where s1 < 50000 and s1 != 100 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime(d0s0))
+              resultSet.getString(maxTime(d0s0))
                   + ","
                   + resultSet.getString(maxTime(d0s1))
                   + ","
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationSmallDataIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationSmallDataIT.java
index aec2ae3a48f..7ed236411df 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationSmallDataIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationSmallDataIT.java
@@ -129,7 +129,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void countWithTimeFilterTest() {
-    String[] retArray = new String[] {"0,3,7,4,5,1"};
+    String[] retArray = new String[] {"3,7,4,5,1"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -141,9 +141,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -165,7 +163,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void countWithoutFilterTest() {
-    String[] retArray = new String[] {"0,4,0,6,1"};
+    String[] retArray = new String[] {"4,0,6,1"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -177,9 +175,7 @@ public class IoTDBAggregationSmallDataIT {
               "SELECT count(d0.s0),count(d1.s1),count(d0.s3),count(d0.s4) FROM 
root.vehicle")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d1s1))
                   + ","
@@ -199,7 +195,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void maxValueWithoutFilterTest() {
-    String[] retArray = new String[] {"0,22222,null"};
+    String[] retArray = new String[] {"22222,null"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -220,11 +216,7 @@ public class IoTDBAggregationSmallDataIT {
           statement.executeQuery("SELECT max_value(d0.s0),max_value(d1.s1) 
FROM root.vehicle")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
-                  + ","
-                  + resultSet.getString(maxValue(d1s1));
+              resultSet.getString(maxValue(d0s0)) + "," + 
resultSet.getString(maxValue(d1s1));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -238,7 +230,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void extremeWithoutFilterTest() {
-    String[] retArray = new String[] {"0,22222,null"};
+    String[] retArray = new String[] {"22222,null"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -259,11 +251,7 @@ public class IoTDBAggregationSmallDataIT {
           statement.executeQuery("SELECT extreme(d0.s0),extreme(d1.s1) FROM 
root.vehicle")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(extreme(d0s0))
-                  + ","
-                  + resultSet.getString(extreme(d1s1));
+              resultSet.getString(extreme(d0s0)) + "," + 
resultSet.getString(extreme(d1s1));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -277,7 +265,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void firstValueWithoutFilterTest() {
-    String[] retArray = new String[] {"0,90,null,aaaaa"};
+    String[] retArray = new String[] {"90,null,aaaaa"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -289,9 +277,7 @@ public class IoTDBAggregationSmallDataIT {
               "SELECT first_value(d0.s0),first_value(d1.s1),first_value(d0.s3) 
FROM root.vehicle")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
+              resultSet.getString(firstValue(d0s0))
                   + ","
                   + resultSet.getString(firstValue(d1s1))
                   + ","
@@ -309,7 +295,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void lastValueWithoutFilterTest() {
-    String[] retArray = new String[] {"0,22222,null,good"};
+    String[] retArray = new String[] {"22222,null,good"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -321,9 +307,7 @@ public class IoTDBAggregationSmallDataIT {
               "SELECT last_value(d0.s0),last_value(d1.s1),last_value(d0.s3) 
FROM root.vehicle")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
+              resultSet.getString(lastValue(d0s0))
                   + ","
                   + resultSet.getString(lastValue(d1s1))
                   + ","
@@ -341,7 +325,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void sumWithoutFilterTest() {
-    String[] retArray = new String[] {"0,22610.0,null"};
+    String[] retArray = new String[] {"22610.0,null"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -351,12 +335,7 @@ public class IoTDBAggregationSmallDataIT {
       try (ResultSet resultSet =
           statement.executeQuery("SELECT sum(d0.s0),sum(d1.s1) FROM 
root.vehicle")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
-                  + ","
-                  + resultSet.getString(sum(d1s1));
+          String ans = resultSet.getString(sum(d0s0)) + "," + 
resultSet.getString(sum(d1s1));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -370,7 +349,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void lastValueWithSingleValueFilterTest() {
-    String[] retArray = new String[] {"0,22222,55555"};
+    String[] retArray = new String[] {"22222,55555"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -380,11 +359,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(lastValue(d0s0))
-                  + ","
-                  + resultSet.getString(lastValue(d0s1));
+              resultSet.getString(lastValue(d0s0)) + "," + 
resultSet.getString(lastValue(d0s1));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -398,7 +373,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void firstValueWithSingleValueFilterTest() {
-    String[] retArray = new String[] {"0,99,180"};
+    String[] retArray = new String[] {"99,180"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -408,11 +383,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(firstValue(d0s0))
-                  + ","
-                  + resultSet.getString(firstValue(d0s1));
+              resultSet.getString(firstValue(d0s0)) + "," + 
resultSet.getString(firstValue(d0s1));
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
@@ -426,7 +397,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void sumWithSingleValueFilterTest() {
-    String[] retArray = new String[] {"0,22321.0,55934.0,1029"};
+    String[] retArray = new String[] {"22321.0,55934.0,1029"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -436,9 +407,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(sum(d0s0))
+              resultSet.getString(sum(d0s0))
                   + ","
                   + resultSet.getString(sum(d0s1))
                   + ","
@@ -456,7 +425,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void avgWithSingleValueFilterTest() {
-    String[] retArray = new String[] {"0,11160.5,18645,206"};
+    String[] retArray = new String[] {"11160.5,18645,206"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -466,9 +435,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(avg(d0s0))
+              resultSet.getString(avg(d0s0))
                   + ","
                   + Math.round(resultSet.getDouble(avg(d0s1)))
                   + ","
@@ -486,7 +453,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void countWithSingleValueFilterTest() {
-    String[] retArray = new String[] {"0,2,3,5,1,0"};
+    String[] retArray = new String[] {"2,3,5,1,0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -498,9 +465,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count(d0s0))
+              resultSet.getString(count(d0s0))
                   + ","
                   + resultSet.getString(count(d0s1))
                   + ","
@@ -522,7 +487,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void minTimeWithMultiValueFiltersTest() {
-    String[] retArray = new String[] {"0,104,1,2,101,100"};
+    String[] retArray = new String[] {"104,1,2,101,100"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -534,9 +499,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minTime(d0s0))
+              resultSet.getString(minTime(d0s0))
                   + ","
                   + resultSet.getString(minTime(d0s1))
                   + ","
@@ -558,7 +521,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void maxTimeWithMultiValueFiltersTest() {
-    String[] retArray = new String[] {"0,105,105,105,102,100"};
+    String[] retArray = new String[] {"105,105,105,102,100"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -570,9 +533,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxTime(d0s0))
+              resultSet.getString(maxTime(d0s0))
                   + ","
                   + resultSet.getString(maxTime(d0s1))
                   + ","
@@ -594,7 +555,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void minValueWithMultiValueFiltersTest() {
-    String[] retArray = new String[] {"0,90,180,2.22"};
+    String[] retArray = new String[] {"90,180,2.22"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -606,9 +567,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(minValue(d0s0))
+              resultSet.getString(minValue(d0s0))
                   + ","
                   + resultSet.getString(minValue(d0s1))
                   + ","
@@ -627,7 +586,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void maxValueWithMultiValueFiltersTest() {
-    String[] retArray = new String[] {"0,99,40000,11.11"};
+    String[] retArray = new String[] {"99,40000,11.11"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -639,9 +598,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(maxValue(d0s0))
+              resultSet.getString(maxValue(d0s0))
                   + ","
                   + resultSet.getString(maxValue(d0s1))
                   + ","
@@ -659,7 +616,7 @@ public class IoTDBAggregationSmallDataIT {
 
   @Test
   public void extremeWithMultiValueFiltersTest() throws ClassNotFoundException 
{
-    String[] retArray = new String[] {"0,99,40000,11.11"};
+    String[] retArray = new String[] {"99,40000,11.11"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -672,9 +629,7 @@ public class IoTDBAggregationSmallDataIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(extreme(d0s0))
+              resultSet.getString(extreme(d0s0))
                   + ","
                   + resultSet.getString(extreme(d0s1))
                   + ","
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteAlignedTimeseriesIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteAlignedTimeseriesIT.java
index 3defa886f8d..ab7c7a8fa88 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteAlignedTimeseriesIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteAlignedTimeseriesIT.java
@@ -35,7 +35,6 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.Statement;
 
-import static org.apache.iotdb.itbase.constant.TestConstant.TIMESTAMP_STR;
 import static org.apache.iotdb.itbase.constant.TestConstant.count;
 import static org.junit.Assert.fail;
 
@@ -214,7 +213,7 @@ public class IoTDBDeleteAlignedTimeseriesIT extends 
AbstractSchemaIT {
 
   @Test
   public void deleteTimeSeriesMultiIntervalTest() {
-    String[] retArray1 = new String[] {"0,0"};
+    String[] retArray1 = new String[] {"0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -232,10 +231,7 @@ public class IoTDBDeleteAlignedTimeseriesIT extends 
AbstractSchemaIT {
           statement.executeQuery(
               "select count(s1) from root.sg.d1 where time >= 3 and time <= 
4")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count("root.sg.d1.s1"));
+          String ans = resultSet.getString(count("root.sg.d1.s1"));
           Assert.assertEquals(retArray1[cnt], ans);
           cnt++;
         }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteTimeSeriesIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteTimeSeriesIT.java
index b737dccf71f..25bc288d51d 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteTimeSeriesIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteTimeSeriesIT.java
@@ -37,7 +37,6 @@ import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import static org.apache.iotdb.itbase.constant.TestConstant.TIMESTAMP_STR;
 import static org.apache.iotdb.itbase.constant.TestConstant.count;
 import static org.junit.Assert.fail;
 
@@ -170,7 +169,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
 
   @Test
   public void deleteTimeSeriesMultiIntervalTest() {
-    String[] retArray1 = new String[] {"0,0"};
+    String[] retArray1 = new String[] {"0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -188,10 +187,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
           statement.executeQuery(
               "select count(s1) from root.sg.d1 where time >= 3 and time <= 
4")) {
         while (resultSet.next()) {
-          String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(count("root.sg.d1.s1"));
+          String ans = resultSet.getString(count("root.sg.d1.s1"));
           Assert.assertEquals(retArray1[cnt], ans);
           cnt++;
         }
@@ -205,7 +201,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
 
   @Test
   public void deleteTimeSeriesAndAutoDeleteDeviceTest() throws Exception {
-    String[] retArray1 = new String[] {"0,4,4,4,4"};
+    String[] retArray1 = new String[] {"4,4,4,4"};
 
     String insertSql = "insert into root.sg.d1(time, s1, s2, s3, s4) 
values(%d, %d, %d, %d, %d)";
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -219,8 +215,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
           statement.executeQuery(
               "select count(s1), count(s2), count(s3), count(s4) from 
root.sg.d1")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg.d1.s1")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg.d1.s" + 
i)));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -246,7 +242,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
 
   @Test
   public void deleteTimeSeriesCrossSchemaRegionTest() throws Exception {
-    String[] retArray1 = new String[] {"0,4,4,4,4"};
+    String[] retArray1 = new String[] {"4,4,4,4"};
 
     String insertSql = "insert into root.sg.d%d(time, s1, s2) values(%d, %d, 
%d)";
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -260,8 +256,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
       int cnt = 0;
       try (ResultSet resultSet = statement.executeQuery("select count(s1) from 
root.sg.*")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg.d1.s1")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg.d" + i + 
".s1")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -282,8 +278,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
       cnt = 0;
       try (ResultSet resultSet = statement.executeQuery("select count(s2) from 
root.sg.*")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg.d1.s2")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg.d" + i + 
".s2")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -296,7 +292,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
 
   @Test
   public void deleteTimeSeriesCrossStorageGroupTest() throws Exception {
-    String[] retArray1 = new String[] {"0,4,4,4,4"};
+    String[] retArray1 = new String[] {"4,4,4,4"};
 
     String insertSql = "insert into root.sg%d.d1(time, s1, s2) values(%d, %d, 
%d)";
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -310,8 +306,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
       int cnt = 0;
       try (ResultSet resultSet = statement.executeQuery("select count(s1) from 
root.*.d1")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg1.d1.s1")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg" + i + 
".d1.s1")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -332,8 +328,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
       cnt = 0;
       try (ResultSet resultSet = statement.executeQuery("select count(s2) from 
root.*.*")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg1.d1.s2")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg" + i + 
".d1.s2")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -351,12 +347,12 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
         Assert.assertFalse(resultSet.next());
       }
 
-      retArray1 = new String[] {"0,4,4"};
+      retArray1 = new String[] {"4,4"};
       cnt = 0;
       try (ResultSet resultSet = statement.executeQuery("select count(s2) from 
root.*.*")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 3; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg3.d1.s2")));
+          for (int i = 4; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg" + i + 
".d1.s2")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -369,7 +365,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
 
   @Test
   public void deleteTimeSeriesWithMultiPatternTest() throws Exception {
-    String[] retArray1 = new String[] {"0,4,4,4,4"};
+    String[] retArray1 = new String[] {"4,4,4,4"};
 
     String insertSql = "insert into root.sg%d.d1(time, s1, s2) values(%d, %d, 
%d)";
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -383,8 +379,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
       int cnt = 0;
       try (ResultSet resultSet = statement.executeQuery("select count(s1) from 
root.*.d1")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg1.d1.s1")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg" + i + 
".d1.s1")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
@@ -450,7 +446,7 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
                         + ": Timeseries [root.**] does not exist or is 
represented by device template"));
       }
 
-      String[] retArray1 = new String[] {"0,4,4,4,4"};
+      String[] retArray1 = new String[] {"4,4,4,4"};
 
       String insertSql = "insert into root.sg%d.d1(time, s1, s2) values(%d, 
%d, %d)";
       for (int i = 1; i <= 4; i++) {
@@ -463,8 +459,8 @@ public class IoTDBDeleteTimeSeriesIT extends 
AbstractSchemaIT {
 
       try (ResultSet resultSet = statement.executeQuery("select count(s1) from 
root.*.d1")) {
         while (resultSet.next()) {
-          StringBuilder ans = new 
StringBuilder(resultSet.getString(TIMESTAMP_STR));
-          for (int i = 1; i <= 4; i++) {
+          StringBuilder ans = new 
StringBuilder(resultSet.getString(count("root.sg1.d1.s1")));
+          for (int i = 2; i <= 4; i++) {
             ans.append(",").append(resultSet.getString(count("root.sg" + i + 
".d1.s1")));
           }
           Assert.assertEquals(retArray1[cnt], ans.toString());
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/udaf/IoTDBUDAFNormalQueryIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/udaf/IoTDBUDAFNormalQueryIT.java
index 56c7a7f4e37..82f61879dd7 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/udaf/IoTDBUDAFNormalQueryIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/udaf/IoTDBUDAFNormalQueryIT.java
@@ -45,7 +45,6 @@ import static org.junit.Assert.fail;
 @Category({LocalStandaloneIT.class, ClusterIT.class})
 public class IoTDBUDAFNormalQueryIT {
   private static final double DELTA = 1E-6;
-  protected static final String TIMESTAMP_STR = "Time";
 
   private static final String[] creationSqls =
       new String[] {
@@ -198,7 +197,7 @@ public class IoTDBUDAFNormalQueryIT {
 
   @Test
   public void singleUDAFTest() {
-    String[] retArray = new String[] {"0,2001,2001,2001,2001", 
"0,7500,7500,7500,7500"};
+    String[] retArray = new String[] {"2001,2001,2001,2001", 
"7500,7500,7500,7500"};
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
 
@@ -210,9 +209,7 @@ public class IoTDBUDAFNormalQueryIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(countUDAF(d0s0))
+              resultSet.getString(countUDAF(d0s0))
                   + ","
                   + resultSet.getString(countUDAF(d0s1))
                   + ","
@@ -231,9 +228,7 @@ public class IoTDBUDAFNormalQueryIT {
                   + "FROM root.vehicle.d0")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(countUDAF(d0s0))
+              resultSet.getString(countUDAF(d0s0))
                   + ","
                   + resultSet.getString(countUDAF(d0s1))
                   + ","
@@ -254,9 +249,7 @@ public class IoTDBUDAFNormalQueryIT {
         cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(countUDAF(d0s0))
+              resultSet.getString(countUDAF(d0s0))
                   + ","
                   + resultSet.getString(countUDAF(d0s1))
                   + ","
@@ -275,9 +268,7 @@ public class IoTDBUDAFNormalQueryIT {
                   + "FROM root.vehicle.d0 order by time desc")) {
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString(countUDAF(d0s0))
+              resultSet.getString(countUDAF(d0s0))
                   + ","
                   + resultSet.getString(countUDAF(d0s1))
                   + ","
@@ -298,8 +289,8 @@ public class IoTDBUDAFNormalQueryIT {
   @Test
   public void multipleUDAFTest() {
     double[][] retArray = {
-      {0.0, 1.4508E7, 7250.374812593702},
-      {0.0, 626750.0, 1250.9980039920158}
+      {1.4508E7, 7250.374812593702},
+      {626750.0, 1250.9980039920158}
     };
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -311,10 +302,9 @@ public class IoTDBUDAFNormalQueryIT {
               "SELECT sum_udaf(s0),avg_udaf(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 
9000")) {
         while (resultSet.next()) {
-          double[] ans = new double[3];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sumUDAF(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avgUDAF(d0s2)));
+          double[] ans = new double[2];
+          ans[0] = Double.parseDouble(resultSet.getString(sumUDAF(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avgUDAF(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DELTA);
           cnt++;
         }
@@ -326,10 +316,9 @@ public class IoTDBUDAFNormalQueryIT {
               "SELECT sum_udaf(s0),avg_udaf(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 1000 AND time <= 
2000")) {
         while (resultSet.next()) {
-          double[] ans = new double[3];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sumUDAF(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avgUDAF(d0s2)));
+          double[] ans = new double[2];
+          ans[0] = Double.parseDouble(resultSet.getString(sumUDAF(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avgUDAF(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DELTA);
           cnt++;
         }
@@ -343,10 +332,9 @@ public class IoTDBUDAFNormalQueryIT {
               "SELECT sum_udaf(s0),avg_udaf(s2)"
                   + "FROM root.vehicle.d0 WHERE time >= 6000 AND time <= 9000 
order by time desc")) {
         while (resultSet.next()) {
-          double[] ans = new double[3];
-          ans[0] = Double.parseDouble(resultSet.getString(TIMESTAMP_STR));
-          ans[1] = Double.parseDouble(resultSet.getString(sumUDAF(d0s0)));
-          ans[2] = Double.parseDouble(resultSet.getString(avgUDAF(d0s2)));
+          double[] ans = new double[2];
+          ans[0] = Double.parseDouble(resultSet.getString(sumUDAF(d0s0)));
+          ans[1] = Double.parseDouble(resultSet.getString(avgUDAF(d0s2)));
           assertArrayEquals(retArray[cnt], ans, DELTA);
           cnt++;
         }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDTFHybridQueryIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDTFHybridQueryIT.java
index 09850109297..abdae02a0fd 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDTFHybridQueryIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDTFHybridQueryIT.java
@@ -124,7 +124,7 @@ public class IoTDBUDTFHybridQueryIT {
 
   @Test
   public void testUserDefinedBuiltInHybridAggregationQuery2() {
-    String[] retArray = new String[] 
{"0,2.0,0.9092974268256817,3.0,-10.0,12.0"};
+    String[] retArray = new String[] {"2.0,0.9092974268256817,3.0,-10.0,12.0"};
 
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
@@ -134,9 +134,7 @@ public class IoTDBUDTFHybridQueryIT {
         int cnt = 0;
         while (resultSet.next()) {
           String ans =
-              resultSet.getString(TIMESTAMP_STR)
-                  + ","
-                  + resultSet.getString("avg(root.vehicle.d1.s1)")
+              resultSet.getString("avg(root.vehicle.d1.s1)")
                   + ","
                   + resultSet.getString("sin(avg(root.vehicle.d1.s2))")
                   + ","
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBNullIdQueryIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBNullIdQueryIT.java
index 36c02ebec8e..b10360ca9f2 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBNullIdQueryIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBNullIdQueryIT.java
@@ -33,7 +33,9 @@ import org.junit.runner.RunWith;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
 import java.sql.Statement;
+import java.sql.Types;
 
 import static org.apache.iotdb.db.it.utils.TestUtils.defaultFormatDataTime;
 import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData;
@@ -182,6 +184,24 @@ public class IoTDBNullIdQueryIT {
       resultSet =
           statement.executeQuery("select * from testNullId where s2 not 
between false and true");
       assertFalse(resultSet.next());
+
+      // Test same column name
+      resultSet = statement.executeQuery("select time, s1 as a, s2 as a from 
testNullId");
+      result = defaultFormatDataTime(1) + ",0,false";
+      ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+      assertEquals(3, resultSetMetaData.getColumnCount());
+      assertEquals("time", resultSetMetaData.getColumnName(1));
+      assertEquals(Types.TIMESTAMP, resultSetMetaData.getColumnType(1));
+      assertEquals("a", resultSetMetaData.getColumnName(2));
+      assertEquals(Types.INTEGER, resultSetMetaData.getColumnType(2));
+      assertEquals("a", resultSetMetaData.getColumnName(3));
+      assertEquals(Types.BOOLEAN, resultSetMetaData.getColumnType(3));
+
+      assertTrue(resultSet.next());
+      ans = resultSet.getString(1) + "," + resultSet.getString(2) + "," + 
resultSet.getString(3);
+
+      assertEquals(result, ans);
+      assertFalse(resultSet.next());
     }
   }
 }
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index b803e0df55c..f5f7a59409d 100644
--- a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -734,7 +734,7 @@ public abstract class AbstractCli {
 
   private static String getStringByColumnIndex(
       IoTDBJDBCResultSet resultSet, int columnIndex, ZoneId zoneId) throws 
SQLException {
-    TSDataType type = 
TSDataType.valueOf(resultSet.getColumnTypeByIndex(columnIndex));
+    TSDataType type = resultSet.getColumnTypeByIndex(columnIndex);
     switch (type) {
       case BOOLEAN:
       case INT32:
diff --git 
a/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/SessionDataSet.java
 
b/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/SessionDataSet.java
index e55aca876aa..81e04d4c53b 100644
--- 
a/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/SessionDataSet.java
+++ 
b/iotdb-client/isession/src/main/java/org/apache/iotdb/isession/SessionDataSet.java
@@ -57,7 +57,8 @@ public class SessionDataSet implements ISessionDataSet {
       boolean moreData,
       ZoneId zoneId,
       int timeFactor,
-      boolean tableModel) {
+      boolean tableModel,
+      List<Integer> columnIndex2TsBlockColumnIndexList) {
     this.ioTDBRpcDataSet =
         new IoTDBRpcDataSet(
             sql,
@@ -76,7 +77,8 @@ public class SessionDataSet implements ISessionDataSet {
             zoneId,
             RpcUtils.DEFAULT_TIME_FORMAT,
             timeFactor,
-            tableModel);
+            tableModel,
+            columnIndex2TsBlockColumnIndexList);
   }
 
   @SuppressWarnings("squid:S107") // ignore Methods should not have too many 
parameters
@@ -96,7 +98,8 @@ public class SessionDataSet implements ISessionDataSet {
       int fetchSize,
       ZoneId zoneId,
       int timeFactor,
-      boolean tableModel) {
+      boolean tableModel,
+      List<Integer> columnIndex2TsBlockColumnIndexList) {
     this.ioTDBRpcDataSet =
         new IoTDBRpcDataSet(
             sql,
@@ -115,30 +118,31 @@ public class SessionDataSet implements ISessionDataSet {
             zoneId,
             RpcUtils.DEFAULT_TIME_FORMAT,
             timeFactor,
-            tableModel);
+            tableModel,
+            columnIndex2TsBlockColumnIndexList);
   }
 
   public int getFetchSize() {
-    return ioTDBRpcDataSet.fetchSize;
+    return ioTDBRpcDataSet.getFetchSize();
   }
 
   public void setFetchSize(int fetchSize) {
-    ioTDBRpcDataSet.fetchSize = fetchSize;
+    ioTDBRpcDataSet.setFetchSize(fetchSize);
   }
 
   @Override
   public List<String> getColumnNames() {
-    return new ArrayList<>(ioTDBRpcDataSet.columnNameList);
+    return new ArrayList<>(ioTDBRpcDataSet.getColumnNameList());
   }
 
   @Override
   public List<String> getColumnTypes() {
-    return new ArrayList<>(ioTDBRpcDataSet.columnTypeList);
+    return new ArrayList<>(ioTDBRpcDataSet.getColumnTypeList());
   }
 
   @Override
   public boolean hasNext() throws StatementExecutionException, 
IoTDBConnectionException {
-    if (ioTDBRpcDataSet.hasCachedRecord) {
+    if (ioTDBRpcDataSet.hasCachedRecord()) {
       return true;
     } else {
       return ioTDBRpcDataSet.next();
@@ -152,7 +156,7 @@ public class SessionDataSet implements ISessionDataSet {
         i++) {
       Field field;
 
-      String columnName = ioTDBRpcDataSet.columnNameList.get(i);
+      String columnName = ioTDBRpcDataSet.getColumnNameList().get(i);
 
       if (!ioTDBRpcDataSet.isNull(columnName)) {
         TSDataType dataType = ioTDBRpcDataSet.getDataType(columnName);
@@ -194,7 +198,7 @@ public class SessionDataSet implements ISessionDataSet {
       }
       outFields.add(field);
     }
-    return new RowRecord(ioTDBRpcDataSet.time, outFields);
+    return new RowRecord(ioTDBRpcDataSet.getCurrentRowTime(), outFields);
   }
 
   /**
@@ -208,10 +212,10 @@ public class SessionDataSet implements ISessionDataSet {
    */
   @Override
   public RowRecord next() throws StatementExecutionException, 
IoTDBConnectionException {
-    if (!ioTDBRpcDataSet.hasCachedRecord && !hasNext()) {
+    if (!ioTDBRpcDataSet.hasCachedRecord() && !hasNext()) {
       return null;
     }
-    ioTDBRpcDataSet.hasCachedRecord = false;
+    ioTDBRpcDataSet.setHasCachedRecord(false);
 
     return constructRowRecordFromValueArray();
   }
@@ -316,11 +320,11 @@ public class SessionDataSet implements ISessionDataSet {
     }
 
     public List<String> getColumnNameList() {
-      return ioTDBRpcDataSet.columnNameList;
+      return ioTDBRpcDataSet.getColumnNameList();
     }
 
     public List<String> getColumnTypeList() {
-      return ioTDBRpcDataSet.columnTypeList;
+      return ioTDBRpcDataSet.getColumnTypeList();
     }
   }
 }
diff --git 
a/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSet.java 
b/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSet.java
index 19e8004a33f..965ddd9c773 100644
--- 
a/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSet.java
+++ 
b/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSet.java
@@ -60,6 +60,8 @@ import java.time.ZoneId;
 import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import static org.apache.iotdb.rpc.RpcUtils.convertToTimestamp;
 
@@ -95,7 +97,8 @@ public class IoTDBJDBCResultSet implements ResultSet {
       boolean moreData,
       ZoneId zoneId,
       Charset charset,
-      boolean tableModel)
+      boolean tableModel,
+      List<Integer> columnIndex2TsBlockColumnIndexList)
       throws SQLException {
     this.ioTDBRpcDataSet =
         new IoTDBRpcDataSet(
@@ -115,7 +118,8 @@ public class IoTDBJDBCResultSet implements ResultSet {
             zoneId,
             timeFormat,
             statement.getTimeFactor(),
-            tableModel);
+            tableModel,
+            columnIndex2TsBlockColumnIndexList);
     this.statement = statement;
     this.columnTypeList = columnTypeList;
     if (tracingInfo != null) {
@@ -160,7 +164,8 @@ public class IoTDBJDBCResultSet implements ResultSet {
             zoneId,
             timeFormat,
             ((IoTDBStatement) statement).getTimeFactor(),
-            false);
+            false,
+            IntStream.range(0, 
columnNameList.size()).boxed().collect(Collectors.toList()));
     this.statement = (IoTDBStatement) statement;
     this.columnTypeList = columnTypeList;
     if (tracingInfo != null) {
@@ -421,7 +426,7 @@ public class IoTDBJDBCResultSet implements ResultSet {
   @Override
   public double getDouble(int columnIndex) throws SQLException {
     try {
-      if (ioTDBRpcDataSet.columnTypeList.get(columnIndex - 1).equals("FLOAT")) 
{
+      if (TSDataType.FLOAT == ioTDBRpcDataSet.getDataType(columnIndex)) {
         return ioTDBRpcDataSet.getFloat(columnIndex);
       }
       return getDouble(ioTDBRpcDataSet.findColumnNameByIndex(columnIndex));
@@ -433,10 +438,7 @@ public class IoTDBJDBCResultSet implements ResultSet {
   @Override
   public double getDouble(String columnName) throws SQLException {
     try {
-      if (ioTDBRpcDataSet
-          .columnTypeList
-          .get(ioTDBRpcDataSet.columnNameList.indexOf(columnName))
-          .equals("FLOAT")) {
+      if (TSDataType.FLOAT == ioTDBRpcDataSet.getDataType(columnName)) {
         return ioTDBRpcDataSet.getFloat(columnName);
       }
       return ioTDBRpcDataSet.getDouble(columnName);
@@ -540,9 +542,9 @@ public class IoTDBJDBCResultSet implements ResultSet {
         nonAlign,
         sgColumns,
         operationTypeColumn,
-        ioTDBRpcDataSet.columnNameList,
-        ioTDBRpcDataSet.columnTypeList,
-        ioTDBRpcDataSet.ignoreTimeStamp);
+        ioTDBRpcDataSet.getColumnNameList(),
+        ioTDBRpcDataSet.getColumnTypeList(),
+        ioTDBRpcDataSet.isIgnoreTimeStamp());
   }
 
   @Override
@@ -761,7 +763,7 @@ public class IoTDBJDBCResultSet implements ResultSet {
 
   @Override
   public boolean isClosed() {
-    return ioTDBRpcDataSet.isClosed;
+    return ioTDBRpcDataSet.isClosed();
   }
 
   @Override
@@ -1245,12 +1247,12 @@ public class IoTDBJDBCResultSet implements ResultSet {
 
   @Override
   public boolean wasNull() {
-    return ioTDBRpcDataSet.lastReadWasNull;
+    return ioTDBRpcDataSet.isLastReadWasNull();
   }
 
   protected String getValueByName(String columnName) throws SQLException {
     try {
-      return ioTDBRpcDataSet.getValueByName(columnName);
+      return ioTDBRpcDataSet.getString(columnName);
     } catch (StatementExecutionException e) {
       throw new SQLException(e.getMessage());
     }
@@ -1258,7 +1260,7 @@ public class IoTDBJDBCResultSet implements ResultSet {
 
   protected Object getObjectByName(String columnName) throws SQLException {
     try {
-      return ioTDBRpcDataSet.getObjectByName(columnName);
+      return ioTDBRpcDataSet.getObject(columnName);
     } catch (StatementExecutionException e) {
       throw new SQLException(e.getMessage());
     }
@@ -1288,7 +1290,7 @@ public class IoTDBJDBCResultSet implements ResultSet {
   }
 
   public boolean isIgnoreTimeStamp() {
-    return ioTDBRpcDataSet.ignoreTimeStamp;
+    return ioTDBRpcDataSet.isIgnoreTimeStamp();
   }
 
   public String getOperationType() {
@@ -1303,11 +1305,7 @@ public class IoTDBJDBCResultSet implements ResultSet {
     return sgColumns;
   }
 
-  public String getColumnTypeByIndex(int columnIndex) {
-    if (!isIgnoreTimeStamp() && columnIndex == 1) {
-      return TSDataType.TIMESTAMP.name();
-    }
-
-    return ioTDBRpcDataSet.columnTypeList.get(columnIndex - 1);
+  public TSDataType getColumnTypeByIndex(int columnIndex) {
+    return ioTDBRpcDataSet.getDataType(columnIndex);
   }
 }
diff --git 
a/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java 
b/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index e7e045252e3..c38da4dc655 100644
--- a/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -347,7 +347,8 @@ public class IoTDBStatement implements Statement {
                 execResp.moreData,
                 zoneId,
                 charset,
-                execResp.isSetTableModel() && execResp.isTableModel());
+                execResp.isSetTableModel() && execResp.isTableModel(),
+                execResp.getColumnIndex2TsBlockColumnIndexList());
       }
       return true;
     }
@@ -490,7 +491,8 @@ public class IoTDBStatement implements Statement {
               execResp.moreData,
               zoneId,
               charset,
-              execResp.isSetTableModel() && execResp.isTableModel());
+              execResp.isSetTableModel() && execResp.isTableModel(),
+              execResp.getColumnIndex2TsBlockColumnIndexList());
     }
     return resultSet;
   }
diff --git 
a/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
 
b/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
index bba5bfb094d..ab29a141399 100644
--- 
a/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
+++ 
b/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadataTest.java
@@ -41,6 +41,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.time.ZoneId;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -143,10 +144,11 @@ public class IoTDBDatabaseMetadataTest {
     when(execStatementResp.isSetTableModel()).thenReturn(false);
 
     execStatementResp.moreData = false;
-    execStatementResp.ignoreTimeStamp = true;
+    when(execStatementResp.isIgnoreTimeStamp()).thenReturn(true);
+    
when(execStatementResp.getColumnIndex2TsBlockColumnIndexList()).thenReturn(Arrays.asList(0));
     execStatementResp.columnNameIndexMap = columnNameIndexMap;
     ResultSet rs = databaseMetaData.getCatalogs();
-    assertEquals(2, rs.findColumn("TYPE_CAT"));
+    assertEquals(1, rs.findColumn("TYPE_CAT"));
   }
 
   @Test
diff --git 
a/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
 
b/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
index 999c87a9e9a..3fb60b8760d 100644
--- 
a/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
+++ 
b/iotdb-client/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
@@ -174,6 +174,15 @@ public class IoTDBJDBCResultSetTest {
     when(execResp.isSetQueryId()).thenReturn(true);
     when(execResp.getQueryId()).thenReturn(queryId);
     when(execResp.isSetTableModel()).thenReturn(false);
+    when(execResp.isIgnoreTimeStamp()).thenReturn(false);
+    List<Integer> columnIndex2TsBlockColumnIndexList = new 
ArrayList<>(columns.size());
+    columnIndex2TsBlockColumnIndexList.add(0);
+    columnIndex2TsBlockColumnIndexList.add(1);
+    columnIndex2TsBlockColumnIndexList.add(2);
+    columnIndex2TsBlockColumnIndexList.add(0);
+
+    when(execResp.getColumnIndex2TsBlockColumnIndexList())
+        .thenReturn(columnIndex2TsBlockColumnIndexList);
     doReturn("FLOAT")
         .doReturn("INT64")
         .doReturn("INT32")
diff --git 
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
 
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
index d7dfd63b66c..95a2239dec8 100644
--- 
a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
+++ 
b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java
@@ -41,43 +41,47 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import static org.apache.iotdb.rpc.RpcUtils.convertToTimestamp;
 import static org.apache.iotdb.rpc.RpcUtils.getTimePrecision;
 
 public class IoTDBRpcDataSet {
 
-  public static final String TIMESTAMP_STR = "Time";
-  public String sql;
-  public boolean isClosed = false;
-  public IClientRPCService.Iface client;
-  public List<String> columnNameList; // no deduplication
-  public List<String> columnTypeList; // no deduplication
+  private static final String TIMESTAMP_STR = "Time";
+  private static final TsBlockSerde SERDE = new TsBlockSerde();
+
+  private final String sql;
+  private boolean isClosed = false;
+  private IClientRPCService.Iface client;
+  private final List<String> columnNameList; // no deduplication
+  private final List<String> columnTypeList; // no deduplication
   private final Map<String, Integer>
       columnOrdinalMap; // used because the server returns deduplicated columns
   private final Map<String, Integer> columnName2TsBlockColumnIndexMap;
-  private final List<TSDataType> columnTypeDeduplicatedList; // deduplicated 
from columnTypeList
-  public int fetchSize;
-  public final long timeout;
-  public boolean hasCachedRecord = false;
-  public boolean lastReadWasNull;
-
-  public long sessionId;
-  public long queryId;
-  public long statementId;
-  public long time;
-  public boolean ignoreTimeStamp;
+
+  // column index -> TsBlock column index
+  private final List<Integer> columnIndex2TsBlockColumnIndexList;
+
+  private final List<TSDataType> dataTypeForTsBlockColumn;
+  private int fetchSize;
+  private final long timeout;
+  private boolean hasCachedRecord = false;
+  private boolean lastReadWasNull;
+
+  private final long sessionId;
+  private final long queryId;
+  private final long statementId;
+  private long time;
+  private final boolean ignoreTimeStamp;
   // indicates that there is still more data in server side and we can call 
fetchResult to get more
-  public boolean moreData;
-
-  public static final TsBlockSerde serde = new TsBlockSerde();
-  public List<ByteBuffer> queryResult;
-  public TsBlock curTsBlock;
-  public int queryResultSize; // the length of queryResult
-  public int queryResultIndex; // the index of bytebuffer in queryResult
-  public int tsBlockSize; // the size of current tsBlock
-  public int tsBlockIndex; // the row index in current tsBlock
+  private boolean moreData;
+
+  private List<ByteBuffer> queryResult;
+  private TsBlock curTsBlock;
+  private int queryResultSize; // the length of queryResult
+  private int queryResultIndex; // the index of bytebuffer in queryResult
+  private int tsBlockSize; // the size of current tsBlock
+  private int tsBlockIndex; // the row index in current tsBlock
   private final ZoneId zoneId;
   private final String timeFormat;
 
@@ -85,9 +89,6 @@ public class IoTDBRpcDataSet {
 
   private final String timePrecision;
 
-  // 2 for tree model and 1 for table model
-  private final int startIndex;
-
   @SuppressWarnings({"squid:S3776", "squid:S107"}) // Suppress high Cognitive 
Complexity warning
   public IoTDBRpcDataSet(
       String sql,
@@ -106,10 +107,11 @@ public class IoTDBRpcDataSet {
       ZoneId zoneId,
       String timeFormat,
       int timeFactor,
-      boolean tableModel) {
-    this.startIndex = tableModel ? 1 : 2;
+      boolean tableModel,
+      List<Integer> columnIndex2TsBlockColumnIndexList) {
     this.sessionId = sessionId;
     this.statementId = statementId;
+    // only used for tree model, table model this field will always be true
     this.ignoreTimeStamp = ignoreTimeStamp;
     this.sql = sql;
     this.queryId = queryId;
@@ -120,51 +122,63 @@ public class IoTDBRpcDataSet {
 
     this.columnNameList = new ArrayList<>();
     this.columnTypeList = new ArrayList<>();
-    if (!ignoreTimeStamp) {
-      this.columnNameList.add(TIMESTAMP_STR);
-      this.columnTypeList.add(String.valueOf(TSDataType.INT64));
-    }
-    // deduplicate and map
     this.columnOrdinalMap = new HashMap<>();
     this.columnName2TsBlockColumnIndexMap = new HashMap<>();
+    int columnStartIndex = 1;
+    int resultSetColumnSize = columnNameList.size();
+
+    // newly generated or updated columnIndex2TsBlockColumnIndexList.size() 
may not be equal to
+    // columnNameList.size()
+    // so we need startIndexForColumnIndex2TsBlockColumnIndexList to adjust 
the mapping relation
+    int startIndexForColumnIndex2TsBlockColumnIndexList = 0;
+
+    // for Time Column in tree model which should always be the first column 
and its index for
+    // TsBlockColumn is -1
     if (!ignoreTimeStamp) {
+      this.columnNameList.add(TIMESTAMP_STR);
+      this.columnTypeList.add(String.valueOf(TSDataType.INT64));
       this.columnName2TsBlockColumnIndexMap.put(TIMESTAMP_STR, -1);
       this.columnOrdinalMap.put(TIMESTAMP_STR, 1);
+      if (columnIndex2TsBlockColumnIndexList != null) {
+        columnIndex2TsBlockColumnIndexList.add(0, -1);
+        startIndexForColumnIndex2TsBlockColumnIndexList = 1;
+      }
+      columnStartIndex++;
+      resultSetColumnSize++;
     }
 
-    // deduplicate and map
-    if (columnNameIndex != null) {
-      int deduplicatedColumnSize =
-          
columnNameIndex.values().stream().mapToInt(Integer::intValue).max().orElse(0) + 
1;
-      this.columnTypeDeduplicatedList = new 
ArrayList<>(deduplicatedColumnSize);
-      for (int i = 0; i < deduplicatedColumnSize; i++) {
-        columnTypeDeduplicatedList.add(null);
+    if (columnIndex2TsBlockColumnIndexList == null) {
+      columnIndex2TsBlockColumnIndexList = new 
ArrayList<>(resultSetColumnSize);
+      if (!ignoreTimeStamp) {
+        startIndexForColumnIndex2TsBlockColumnIndexList = 1;
+        columnIndex2TsBlockColumnIndexList.add(-1);
       }
-      for (int i = 0; i < columnNameList.size(); i++) {
-        String name = columnNameList.get(i);
-        this.columnNameList.add(name);
-        this.columnTypeList.add(columnTypeList.get(i));
-        if (!columnName2TsBlockColumnIndexMap.containsKey(name)) {
-          int index = columnNameIndex.get(name);
-          if (columnTypeDeduplicatedList.get(index) == null) {
-            columnTypeDeduplicatedList.set(index, 
TSDataType.valueOf(columnTypeList.get(i)));
-          }
-          columnOrdinalMap.put(name, i + startIndex);
-          columnName2TsBlockColumnIndexMap.put(name, index);
-        }
+      for (int i = 0, size = columnNameList.size(); i < size; i++) {
+        columnIndex2TsBlockColumnIndexList.add(i);
       }
-    } else {
-      this.columnTypeDeduplicatedList = new ArrayList<>();
-      AtomicInteger index = new AtomicInteger(startIndex);
-      for (int i = 0; i < columnNameList.size(); i++) {
-        String name = columnNameList.get(i);
-        this.columnNameList.add(name);
-        String columnType = columnTypeList.get(i);
-        this.columnTypeList.add(columnType);
-        Integer ordinal =
-            columnOrdinalMap.computeIfAbsent(
-                name, v -> addColumnTypeListReturnIndex(index, 
TSDataType.valueOf(columnType)));
-        columnName2TsBlockColumnIndexMap.put(name, ordinal - startIndex);
+    }
+
+    int tsBlockColumnSize =
+        
columnIndex2TsBlockColumnIndexList.stream().mapToInt(Integer::intValue).max().orElse(0)
 + 1;
+    this.dataTypeForTsBlockColumn = new ArrayList<>(tsBlockColumnSize);
+    for (int i = 0; i < tsBlockColumnSize; i++) {
+      dataTypeForTsBlockColumn.add(null);
+    }
+
+    for (int i = 0, size = columnNameList.size(); i < size; i++) {
+      String name = columnNameList.get(i);
+      this.columnNameList.add(name);
+      this.columnTypeList.add(columnTypeList.get(i));
+      int tsBlockColumnIndex =
+          columnIndex2TsBlockColumnIndexList.get(
+              startIndexForColumnIndex2TsBlockColumnIndexList + i);
+      if (tsBlockColumnIndex != -1) {
+        TSDataType columnType = TSDataType.valueOf(columnTypeList.get(i));
+        dataTypeForTsBlockColumn.set(tsBlockColumnIndex, columnType);
+      }
+      if (!columnName2TsBlockColumnIndexMap.containsKey(name)) {
+        columnOrdinalMap.put(name, i + columnStartIndex);
+        columnName2TsBlockColumnIndexMap.put(name, tsBlockColumnIndex);
       }
     }
 
@@ -180,11 +194,14 @@ public class IoTDBRpcDataSet {
     this.timeFormat = timeFormat;
     this.timeFactor = timeFactor;
     this.timePrecision = getTimePrecision(timeFactor);
-  }
 
-  public Integer addColumnTypeListReturnIndex(AtomicInteger index, TSDataType 
dataType) {
-    columnTypeDeduplicatedList.add(dataType);
-    return index.getAndIncrement();
+    if (columnIndex2TsBlockColumnIndexList.size() != 
this.columnNameList.size()) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Size of columnIndex2TsBlockColumnIndexList %s doesn't equal to 
size of columnNameList %s.",
+              columnIndex2TsBlockColumnIndexList.size(), 
this.columnNameList.size()));
+    }
+    this.columnIndex2TsBlockColumnIndexList = 
columnIndex2TsBlockColumnIndexList;
   }
 
   public void close() throws StatementExecutionException, TException {
@@ -280,17 +297,17 @@ public class IoTDBRpcDataSet {
     lastReadWasNull = false;
     ByteBuffer byteBuffer = queryResult.get(queryResultIndex);
     queryResultIndex++;
-    curTsBlock = serde.deserialize(byteBuffer);
+    curTsBlock = SERDE.deserialize(byteBuffer);
     tsBlockIndex = -1;
     tsBlockSize = curTsBlock.getPositionCount();
   }
 
   public boolean isNull(int columnIndex) throws StatementExecutionException {
-    return isNull(findColumnNameByIndex(columnIndex));
+    return isNull(getTsBlockColumnIndexForColumnIndex(columnIndex), 
tsBlockIndex);
   }
 
   public boolean isNull(String columnName) {
-    return isNull(getTsBlockColumnIndex(columnName), tsBlockIndex);
+    return isNull(getTsBlockColumnIndexForColumnName(columnName), 
tsBlockIndex);
   }
 
   private boolean isNull(int index, int rowNum) {
@@ -299,15 +316,19 @@ public class IoTDBRpcDataSet {
   }
 
   public boolean getBoolean(int columnIndex) throws 
StatementExecutionException {
-    return getBoolean(findColumnNameByIndex(columnIndex));
+    return 
getBooleanByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
   }
 
   public boolean getBoolean(String columnName) throws 
StatementExecutionException {
+    return 
getBooleanByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private boolean getBooleanByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
-    if (!isNull(index, tsBlockIndex)) {
+    if (!isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = false;
-      return curTsBlock.getColumn(index).getBoolean(tsBlockIndex);
+      return curTsBlock.getColumn(tsBlockColumnIndex).getBoolean(tsBlockIndex);
     } else {
       lastReadWasNull = true;
       return false;
@@ -315,15 +336,19 @@ public class IoTDBRpcDataSet {
   }
 
   public double getDouble(int columnIndex) throws StatementExecutionException {
-    return getDouble(findColumnNameByIndex(columnIndex));
+    return 
getDoubleByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
   }
 
   public double getDouble(String columnName) throws 
StatementExecutionException {
+    return 
getDoubleByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private double getDoubleByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
-    if (!isNull(index, tsBlockIndex)) {
+    if (!isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = false;
-      return curTsBlock.getColumn(index).getDouble(tsBlockIndex);
+      return curTsBlock.getColumn(tsBlockColumnIndex).getDouble(tsBlockIndex);
     } else {
       lastReadWasNull = true;
       return 0;
@@ -331,15 +356,19 @@ public class IoTDBRpcDataSet {
   }
 
   public float getFloat(int columnIndex) throws StatementExecutionException {
-    return getFloat(findColumnNameByIndex(columnIndex));
+    return 
getFloatByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
   }
 
   public float getFloat(String columnName) throws StatementExecutionException {
+    return 
getFloatByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private float getFloatByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
-    if (!isNull(index, tsBlockIndex)) {
+    if (!isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = false;
-      return curTsBlock.getColumn(index).getFloat(tsBlockIndex);
+      return curTsBlock.getColumn(tsBlockColumnIndex).getFloat(tsBlockIndex);
     } else {
       lastReadWasNull = true;
       return 0;
@@ -347,19 +376,23 @@ public class IoTDBRpcDataSet {
   }
 
   public int getInt(int columnIndex) throws StatementExecutionException {
-    return getInt(findColumnNameByIndex(columnIndex));
+    return 
getIntByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
   }
 
   public int getInt(String columnName) throws StatementExecutionException {
+    return 
getIntByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private int getIntByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
-    if (!isNull(index, tsBlockIndex)) {
+    if (!isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = false;
-      TSDataType type = curTsBlock.getColumn(index).getDataType();
+      TSDataType type = curTsBlock.getColumn(tsBlockColumnIndex).getDataType();
       if (type == TSDataType.INT64) {
-        return (int) curTsBlock.getColumn(index).getLong(tsBlockIndex);
+        return (int) 
curTsBlock.getColumn(tsBlockColumnIndex).getLong(tsBlockIndex);
       } else {
-        return curTsBlock.getColumn(index).getInt(tsBlockIndex);
+        return curTsBlock.getColumn(tsBlockColumnIndex).getInt(tsBlockIndex);
       }
     } else {
       lastReadWasNull = true;
@@ -368,25 +401,30 @@ public class IoTDBRpcDataSet {
   }
 
   public long getLong(int columnIndex) throws StatementExecutionException {
-    return getLong(findColumnNameByIndex(columnIndex));
+    return 
getLongByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
   }
 
   public long getLong(String columnName) throws StatementExecutionException {
+    int index = getTsBlockColumnIndexForColumnName(columnName);
+    return getLongByTsBlockColumnIndex(index);
+  }
+
+  private long getLongByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
 
     // take care of time column
-    if (index < 0) {
+    if (tsBlockColumnIndex < 0) {
       lastReadWasNull = false;
       return curTsBlock.getTimeByIndex(tsBlockIndex);
     } else {
-      if (!isNull(index, tsBlockIndex)) {
+      if (!isNull(tsBlockColumnIndex, tsBlockIndex)) {
         lastReadWasNull = false;
-        TSDataType type = curTsBlock.getColumn(index).getDataType();
+        TSDataType type = 
curTsBlock.getColumn(tsBlockColumnIndex).getDataType();
         if (type == TSDataType.INT32) {
-          return curTsBlock.getColumn(index).getInt(tsBlockIndex);
+          return curTsBlock.getColumn(tsBlockColumnIndex).getInt(tsBlockIndex);
         } else {
-          return curTsBlock.getColumn(index).getLong(tsBlockIndex);
+          return 
curTsBlock.getColumn(tsBlockColumnIndex).getLong(tsBlockIndex);
         }
       } else {
         lastReadWasNull = true;
@@ -396,15 +434,19 @@ public class IoTDBRpcDataSet {
   }
 
   public Binary getBinary(int columIndex) throws StatementExecutionException {
-    return getBinary(findColumnNameByIndex(columIndex));
+    return 
getBinaryTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columIndex));
   }
 
   public Binary getBinary(String columnName) throws 
StatementExecutionException {
+    return 
getBinaryTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private Binary getBinaryTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
-    if (!isNull(index, tsBlockIndex)) {
+    if (!isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = false;
-      return curTsBlock.getColumn(index).getBinary(tsBlockIndex);
+      return curTsBlock.getColumn(tsBlockColumnIndex).getBinary(tsBlockIndex);
     } else {
       lastReadWasNull = true;
       return null;
@@ -412,122 +454,95 @@ public class IoTDBRpcDataSet {
   }
 
   public Object getObject(int columnIndex) throws StatementExecutionException {
-    return getObject(findColumnNameByIndex(columnIndex));
+    return 
getObjectByTsBlockIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
   }
 
   public Object getObject(String columnName) throws 
StatementExecutionException {
-    return getObjectByName(columnName);
-  }
-
-  public String getString(int columnIndex) throws StatementExecutionException {
-    return getString(findColumnNameByIndex(columnIndex));
-  }
-
-  public String getString(String columnName) throws 
StatementExecutionException {
-    return getValueByName(columnName);
-  }
-
-  public Timestamp getTimestamp(int columnIndex) throws 
StatementExecutionException {
-    return getTimestamp(findColumnNameByIndex(columnIndex));
-  }
-
-  public Timestamp getTimestamp(String columnName) throws 
StatementExecutionException {
-    return convertToTimestamp(getLong(columnName), timeFactor);
+    return 
getObjectByTsBlockIndex(getTsBlockColumnIndexForColumnName(columnName));
   }
 
-  public TSDataType getDataType(int columnIndex) throws 
StatementExecutionException {
-    return getDataType(findColumnNameByIndex(columnIndex));
-  }
-
-  public TSDataType getDataType(String columnName) {
-    final int index = getTsBlockColumnIndex(columnName);
-    if (index == -1) {
-      return TSDataType.TIMESTAMP;
-    } else if (index >= 0 && index < columnTypeDeduplicatedList.size()) {
-      return columnTypeDeduplicatedList.get(index);
-    } else {
-      return null;
-    }
-  }
-
-  public int findColumn(String columnName) {
-    return columnOrdinalMap.get(columnName);
-  }
-
-  public String getValueByName(String columnName) throws 
StatementExecutionException {
+  private Object getObjectByTsBlockIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    // to keep compatibility, tree model should return a long value for time 
column
-    if (startIndex == 2 && columnName.equals(TIMESTAMP_STR)) {
-      return String.valueOf(curTsBlock.getTimeByIndex(tsBlockIndex));
-    }
-    int index = getTsBlockColumnIndex(columnName);
-    if (isNull(index, tsBlockIndex)) {
+    if (isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = true;
       return null;
     }
     lastReadWasNull = false;
-    return getString(index, getDataTypeByTsBlockColumnIndex(index));
-  }
-
-  public String getString(int index, TSDataType tsDataType) {
+    TSDataType tsDataType = 
getDataTypeByTsBlockColumnIndex(tsBlockColumnIndex);
     switch (tsDataType) {
       case BOOLEAN:
-        return 
String.valueOf(curTsBlock.getColumn(index).getBoolean(tsBlockIndex));
       case INT32:
-        return 
String.valueOf(curTsBlock.getColumn(index).getInt(tsBlockIndex));
       case INT64:
-        return String.valueOf(
-            (index == -1
-                ? curTsBlock.getTimeByIndex(tsBlockIndex)
-                : curTsBlock.getColumn(index).getLong(tsBlockIndex)));
+      case FLOAT:
+      case DOUBLE:
+        return 
curTsBlock.getColumn(tsBlockColumnIndex).getObject(tsBlockIndex);
       case TIMESTAMP:
         long timestamp =
-            (index == -1
+            (tsBlockColumnIndex == -1
                 ? curTsBlock.getTimeByIndex(tsBlockIndex)
-                : curTsBlock.getColumn(index).getLong(tsBlockIndex));
-        return RpcUtils.formatDatetime(timeFormat, timePrecision, timestamp, 
zoneId);
-      case FLOAT:
-        return 
String.valueOf(curTsBlock.getColumn(index).getFloat(tsBlockIndex));
-      case DOUBLE:
-        return 
String.valueOf(curTsBlock.getColumn(index).getDouble(tsBlockIndex));
+                : 
curTsBlock.getColumn(tsBlockColumnIndex).getLong(tsBlockIndex));
+        return convertToTimestamp(timestamp, timeFactor);
       case TEXT:
       case STRING:
         return curTsBlock
-            .getColumn(index)
+            .getColumn(tsBlockColumnIndex)
             .getBinary(tsBlockIndex)
             .getStringValue(TSFileConfig.STRING_CHARSET);
       case BLOB:
         return BytesUtils.parseBlobByteArrayToString(
-            curTsBlock.getColumn(index).getBinary(tsBlockIndex).getValues());
+            
curTsBlock.getColumn(tsBlockColumnIndex).getBinary(tsBlockIndex).getValues());
       case DATE:
-        return 
DateUtils.formatDate(curTsBlock.getColumn(index).getInt(tsBlockIndex));
+        return 
DateUtils.formatDate(curTsBlock.getColumn(tsBlockColumnIndex).getInt(tsBlockIndex));
       default:
         return null;
     }
   }
 
-  public Object getObjectByName(String columnName) throws 
StatementExecutionException {
+  public String getString(int columnIndex) throws StatementExecutionException {
+    return 
getStringByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
+  }
+
+  public String getString(String columnName) throws 
StatementExecutionException {
+    return 
getStringByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private String getStringByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
     checkRecord();
-    int index = getTsBlockColumnIndex(columnName);
-    if (isNull(index, tsBlockIndex)) {
+    // to keep compatibility, tree model should return a long value for time 
column
+    if (tsBlockColumnIndex == -1) {
+      return String.valueOf(curTsBlock.getTimeByIndex(tsBlockIndex));
+    }
+    if (isNull(tsBlockColumnIndex, tsBlockIndex)) {
       lastReadWasNull = true;
       return null;
     }
     lastReadWasNull = false;
-    TSDataType tsDataType = getDataTypeByTsBlockColumnIndex(index);
+    return getString(tsBlockColumnIndex, 
getDataTypeByTsBlockColumnIndex(tsBlockColumnIndex));
+  }
+
+  private String getString(int index, TSDataType tsDataType) {
     switch (tsDataType) {
       case BOOLEAN:
+        return 
String.valueOf(curTsBlock.getColumn(index).getBoolean(tsBlockIndex));
       case INT32:
+        return 
String.valueOf(curTsBlock.getColumn(index).getInt(tsBlockIndex));
       case INT64:
-      case FLOAT:
-      case DOUBLE:
-        return curTsBlock.getColumn(index).getObject(tsBlockIndex);
+        return String.valueOf(
+            (index == -1
+                ? curTsBlock.getTimeByIndex(tsBlockIndex)
+                : curTsBlock.getColumn(index).getLong(tsBlockIndex)));
       case TIMESTAMP:
         long timestamp =
             (index == -1
                 ? curTsBlock.getTimeByIndex(tsBlockIndex)
                 : curTsBlock.getColumn(index).getLong(tsBlockIndex));
-        return convertToTimestamp(timestamp, timeFactor);
+        return RpcUtils.formatDatetime(timeFormat, timePrecision, timestamp, 
zoneId);
+      case FLOAT:
+        return 
String.valueOf(curTsBlock.getColumn(index).getFloat(tsBlockIndex));
+      case DOUBLE:
+        return 
String.valueOf(curTsBlock.getColumn(index).getDouble(tsBlockIndex));
       case TEXT:
       case STRING:
         return curTsBlock
@@ -544,10 +559,36 @@ public class IoTDBRpcDataSet {
     }
   }
 
+  public Timestamp getTimestamp(int columnIndex) throws 
StatementExecutionException {
+    return 
getTimestampByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
+  }
+
+  public Timestamp getTimestamp(String columnName) throws 
StatementExecutionException {
+    return 
getTimestampByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
+  private Timestamp getTimestampByTsBlockColumnIndex(int tsBlockColumnIndex)
+      throws StatementExecutionException {
+    long timestamp = getLongByTsBlockColumnIndex(tsBlockColumnIndex);
+    return convertToTimestamp(timestamp, timeFactor);
+  }
+
+  public TSDataType getDataType(int columnIndex) {
+    return 
getDataTypeByTsBlockColumnIndex(getTsBlockColumnIndexForColumnIndex(columnIndex));
+  }
+
+  public TSDataType getDataType(String columnName) {
+    return 
getDataTypeByTsBlockColumnIndex(getTsBlockColumnIndexForColumnName(columnName));
+  }
+
   private TSDataType getDataTypeByTsBlockColumnIndex(int tsBlockColumnIndex) {
     return tsBlockColumnIndex < 0
         ? TSDataType.TIMESTAMP
-        : columnTypeDeduplicatedList.get(tsBlockColumnIndex);
+        : dataTypeForTsBlockColumn.get(tsBlockColumnIndex);
+  }
+
+  public int findColumn(String columnName) {
+    return columnOrdinalMap.get(columnName);
   }
 
   public String findColumnNameByIndex(int columnIndex) throws 
StatementExecutionException {
@@ -562,14 +603,18 @@ public class IoTDBRpcDataSet {
   }
 
   // return -1 for time column of tree model
-  private int getTsBlockColumnIndex(String columnName) {
+  private int getTsBlockColumnIndexForColumnName(String columnName) {
     Integer index = columnName2TsBlockColumnIndexMap.get(columnName);
     if (index == null) {
-      throw new IllegalArgumentException("Unknown column name :" + columnName);
+      throw new IllegalArgumentException("Unknown column name: " + columnName);
     }
     return index;
   }
 
+  private int getTsBlockColumnIndexForColumnIndex(int columnIndex) {
+    return columnIndex2TsBlockColumnIndexList.get(columnIndex - 1);
+  }
+
   public void checkRecord() throws StatementExecutionException {
     if (queryResultIndex > queryResultSize
         || tsBlockIndex >= tsBlockSize
@@ -586,4 +631,44 @@ public class IoTDBRpcDataSet {
   public int getColumnSize() {
     return columnNameList.size();
   }
+
+  public List<String> getColumnTypeList() {
+    return columnTypeList;
+  }
+
+  public List<String> getColumnNameList() {
+    return columnNameList;
+  }
+
+  public boolean isClosed() {
+    return isClosed;
+  }
+
+  public int getFetchSize() {
+    return fetchSize;
+  }
+
+  public void setFetchSize(int fetchSize) {
+    this.fetchSize = fetchSize;
+  }
+
+  public boolean hasCachedRecord() {
+    return hasCachedRecord;
+  }
+
+  public void setHasCachedRecord(boolean hasCachedRecord) {
+    this.hasCachedRecord = hasCachedRecord;
+  }
+
+  public boolean isLastReadWasNull() {
+    return lastReadWasNull;
+  }
+
+  public long getCurrentRowTime() {
+    return time;
+  }
+
+  public boolean isIgnoreTimeStamp() {
+    return ignoreTimeStamp;
+  }
 }
diff --git 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
index 7edaee23524..9a59e6dc50f 100644
--- 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
+++ 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
@@ -463,7 +463,8 @@ public class SessionConnection {
         session.fetchSize,
         zoneId,
         timeFactor,
-        execResp.isSetTableModel() && execResp.isTableModel());
+        execResp.isSetTableModel() && execResp.isTableModel(),
+        execResp.getColumnIndex2TsBlockColumnIndexList());
   }
 
   protected void executeNonQueryStatement(String sql)
@@ -565,7 +566,8 @@ public class SessionConnection {
         execResp.moreData,
         zoneId,
         timeFactor,
-        execResp.isSetTableModel() && execResp.isTableModel());
+        execResp.isSetTableModel() && execResp.isTableModel(),
+        execResp.getColumnIndex2TsBlockColumnIndexList());
   }
 
   protected Pair<SessionDataSet, TEndPoint> executeLastDataQueryForOneDevice(
@@ -614,7 +616,8 @@ public class SessionConnection {
             tsExecuteStatementResp.moreData,
             zoneId,
             timeFactor,
-            tsExecuteStatementResp.isSetTableModel() && 
tsExecuteStatementResp.isTableModel()),
+            tsExecuteStatementResp.isSetTableModel() && 
tsExecuteStatementResp.isTableModel(),
+            tsExecuteStatementResp.getColumnIndex2TsBlockColumnIndexList()),
         redirectedEndPoint);
   }
 
@@ -658,7 +661,8 @@ public class SessionConnection {
         tsExecuteStatementResp.moreData,
         zoneId,
         timeFactor,
-        tsExecuteStatementResp.isSetTableModel() && 
tsExecuteStatementResp.isTableModel());
+        tsExecuteStatementResp.isSetTableModel() && 
tsExecuteStatementResp.isTableModel(),
+        tsExecuteStatementResp.getColumnIndex2TsBlockColumnIndexList());
   }
 
   protected SessionDataSet executeAggregationQuery(
@@ -742,7 +746,8 @@ public class SessionConnection {
         tsExecuteStatementResp.moreData,
         zoneId,
         timeFactor,
-        tsExecuteStatementResp.isSetTableModel() && 
tsExecuteStatementResp.isTableModel());
+        tsExecuteStatementResp.isSetTableModel() && 
tsExecuteStatementResp.isTableModel(),
+        tsExecuteStatementResp.getColumnIndex2TsBlockColumnIndexList());
   }
 
   private TSAggregationQueryReq createAggregationQueryReq(
diff --git 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/ThriftConnection.java
 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/ThriftConnection.java
index 7b62754bb3d..5f9f2a304a5 100644
--- 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/ThriftConnection.java
+++ 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/ThriftConnection.java
@@ -181,7 +181,8 @@ public class ThriftConnection {
         fetchSize,
         zoneId,
         timeFactor,
-        execResp.isSetTableModel() && execResp.isTableModel());
+        execResp.isSetTableModel() && execResp.isTableModel(),
+        execResp.getColumnIndex2TsBlockColumnIndexList());
   }
 
   public void close() {
diff --git 
a/iotdb-client/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
 
b/iotdb-client/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
index 15cbe89aa39..6abce3bdf47 100644
--- 
a/iotdb-client/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
+++ 
b/iotdb-client/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
@@ -1264,7 +1264,8 @@ public class SessionPoolTest {
             10,
             ZoneId.systemDefault(),
             1000,
-            false);
+            false,
+            execResp.getColumnIndex2TsBlockColumnIndexList());
     Mockito.when(session.executeQueryStatement(any(String.class), eq(50)))
         .thenReturn(sessionDataSet);
     sessionDataSetWrapper = sessionPool.executeQueryStatement(sql, 50);
@@ -1475,6 +1476,8 @@ public class SessionPoolTest {
     dataTypeList.add("INT32");
     dataTypeList.add("FLOAT");
 
+    List<Integer> columnIndex2TsBlockColumnIndexList = Arrays.asList(0, 1, 2, 
3);
+
     Mockito.when(execResp.isSetColumns()).thenReturn(true);
     Mockito.when(execResp.getColumns()).thenReturn(columns);
     Mockito.when(execResp.isSetDataTypeList()).thenReturn(true);
@@ -1484,6 +1487,8 @@ public class SessionPoolTest {
     Mockito.when(execResp.isSetQueryId()).thenReturn(true);
     Mockito.when(execResp.getQueryId()).thenReturn(queryId);
     Mockito.when(execResp.isIgnoreTimeStamp()).thenReturn(false);
+    Mockito.when(execResp.getColumnIndex2TsBlockColumnIndexList())
+        .thenReturn(columnIndex2TsBlockColumnIndexList);
 
     SessionDataSet sessionDataSet =
         new SessionDataSet(
@@ -1502,7 +1507,8 @@ public class SessionPoolTest {
             10,
             ZoneId.systemDefault(),
             1000,
-            false);
+            false,
+            execResp.getColumnIndex2TsBlockColumnIndexList());
 
     
Mockito.when(session.executeQueryStatement(any(String.class))).thenReturn(sessionDataSet);
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
index 8b7c7814b3f..4462ad66fce 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
@@ -1123,7 +1123,7 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
       List<ColumnHeader> columnHeaders =
           Collections.singletonList(new ColumnHeader(outputColumnName, 
dataType));
       DatasetHeader header = new DatasetHeader(columnHeaders, false);
-      
header.setColumnToTsBlockIndexMap(Collections.singletonList(outputColumnName));
+      
header.setTreeColumnToTsBlockIndexMap(Collections.singletonList(outputColumnName));
 
       TSExecuteStatementResp resp = createResponse(header, 1);
       TSQueryDataSet queryDataSet = convertTsBlockByFetchSize(blockResult);
@@ -2937,6 +2937,7 @@ public class ClientRPCServiceImpl implements 
IClientRPCServiceWithHandler {
     resp.setDataTypeList(header.getRespDataTypeList());
     resp.setAliasColumns(header.getRespAliasColumns());
     resp.setIgnoreTimeStamp(header.isIgnoreTimestamp());
+    
resp.setColumnIndex2TsBlockColumnIndexList(header.getColumnIndex2TsBlockColumnIndexList());
     resp.setQueryId(queryId);
     resp.setTableModel(
         SESSION_MANAGER.getCurrSessionAndUpdateIdleTime().getSqlDialect()
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeader.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeader.java
index 9f263da4904..8eb177dea8d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeader.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/common/header/DatasetHeader.java
@@ -39,6 +39,7 @@ public class DatasetHeader {
   public static final DatasetHeader EMPTY_HEADER = new DatasetHeader(new 
ArrayList<>(), false);
 
   // column names, data types and aliases of result dataset
+  // !!attention!! there may exist duplicated column names in table model
   private final List<ColumnHeader> columnHeaders;
 
   // indicate whether the result dataset contain timestamp column
@@ -46,6 +47,7 @@ public class DatasetHeader {
 
   // map from output column to output tsBlock index
   private Map<String, Integer> columnToTsBlockIndexMap;
+  private List<Integer> columnIndex2TsBlockColumnIndexList;
 
   // cached field for create response
   private List<String> respColumns;
@@ -58,6 +60,11 @@ public class DatasetHeader {
   public DatasetHeader(List<ColumnHeader> columnHeaders, boolean 
isIgnoreTimestamp) {
     this.columnHeaders = columnHeaders;
     this.isIgnoreTimestamp = isIgnoreTimestamp;
+    int size = columnHeaders.size();
+    this.columnIndex2TsBlockColumnIndexList = new ArrayList<>(size);
+    for (int i = 0; i < size; i++) {
+      columnIndex2TsBlockColumnIndexList.add(i);
+    }
   }
 
   public List<ColumnHeader> getColumnHeaders() {
@@ -68,25 +75,33 @@ public class DatasetHeader {
     return isIgnoreTimestamp;
   }
 
-  public void setColumnToTsBlockIndexMap(List<String> outputColumnNames) {
-    this.columnToTsBlockIndexMap = new HashMap<>();
+  public void setTreeColumnToTsBlockIndexMap(List<String> outputColumnNames) {
+    this.columnToTsBlockIndexMap = new HashMap<>(outputColumnNames.size());
     for (int i = 0; i < outputColumnNames.size(); i++) {
       columnToTsBlockIndexMap.put(outputColumnNames.get(i), i);
     }
+
+    this.columnIndex2TsBlockColumnIndexList = new 
ArrayList<>(columnHeaders.size());
+    for (ColumnHeader columnHeader : columnHeaders) {
+      columnIndex2TsBlockColumnIndexList.add(
+          columnToTsBlockIndexMap.get(columnHeader.getColumnName()));
+    }
   }
 
   public void setTableColumnToTsBlockIndexMap(OutputNode outputNode) {
-    List<Symbol> outputSymbols = outputNode.getChild().getOutputSymbols();
-    Map<Symbol, Integer> outputSymbolsIndexMap = new 
HashMap<>(outputSymbols.size());
-    for (int i = 0; i < outputSymbols.size(); i++) {
-      outputSymbolsIndexMap.put(outputSymbols.get(i), i);
+    List<Symbol> childOutputSymbols = outputNode.getChild().getOutputSymbols();
+    Map<Symbol, Integer> outputSymbolsIndexMap = new 
HashMap<>(childOutputSymbols.size());
+    for (int i = 0; i < childOutputSymbols.size(); i++) {
+      outputSymbolsIndexMap.put(childOutputSymbols.get(i), i);
     }
 
     this.columnToTsBlockIndexMap = new HashMap<>();
+    this.columnIndex2TsBlockColumnIndexList =
+        new ArrayList<>(outputNode.getOutputColumnNames().size());
     for (int i = 0; i < outputNode.getOutputColumnNames().size(); i++) {
-      columnToTsBlockIndexMap.put(
-          outputNode.getOutputColumnNames().get(i),
-          outputSymbolsIndexMap.get(outputNode.getOutputSymbols().get(i)));
+      int index = 
outputSymbolsIndexMap.get(outputNode.getOutputSymbols().get(i));
+      columnToTsBlockIndexMap.put(outputNode.getOutputColumnNames().get(i), 
index);
+      columnIndex2TsBlockColumnIndexList.add(index);
     }
   }
 
@@ -160,6 +175,10 @@ public class DatasetHeader {
     return outputValueColumnCount;
   }
 
+  public List<Integer> getColumnIndex2TsBlockColumnIndexList() {
+    return columnIndex2TsBlockColumnIndexList;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
index 2fd9ee783a7..9b1b2fcc00e 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java
@@ -204,7 +204,7 @@ public class DistributionPlanner {
     if (analysis.getTreeStatement() != null && 
analysis.getTreeStatement().isQuery()) {
       analysis
           .getRespDatasetHeader()
-          
.setColumnToTsBlockIndexMap(optimizedRootWithExchange.getOutputColumnNames());
+          
.setTreeColumnToTsBlockIndexMap(optimizedRootWithExchange.getOutputColumnNames());
     }
 
     SubPlan subPlan = splitFragment(optimizedRootWithExchange);
diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift 
b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift
index 5a1af917732..b36a70fb912 100644
--- a/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift
+++ b/iotdb-protocol/thrift-datanode/src/main/thrift/client.thrift
@@ -73,6 +73,7 @@ struct TSExecuteStatementResp {
   // only be set while executing use XXX successfully
   15: optional string database
   16: optional bool tableModel
+  17: optional list<i32> columnIndex2TsBlockColumnIndexList
 }
 
 enum TSProtocolVersion {


Reply via email to