You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/09/19 01:28:46 UTC

[incubator-iotdb] branch master updated: fix ignoreTimeStamp IOTDB-214; simplify some jdbc interfaces (#392)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6849f79  fix ignoreTimeStamp IOTDB-214; simplify some jdbc interfaces (#392)
6849f79 is described below

commit 6849f79452f451c0ac13f6eec81201d89515f70d
Author: Lei Rui <33...@users.noreply.github.com>
AuthorDate: Thu Sep 19 09:28:41 2019 +0800

    fix ignoreTimeStamp IOTDB-214; simplify some jdbc interfaces (#392)
---
 .../org/apache/iotdb/client/AbstractClient.java    |  12 +-
 .../main/java/org/apache/iotdb/jdbc/Constant.java  |   2 +
 .../org/apache/iotdb/jdbc/IoTDBQueryResultSet.java | 353 +++++++++++----------
 .../org/apache/iotdb/jdbc/IoTDBResultMetadata.java |  62 ++--
 .../java/org/apache/iotdb/jdbc/IoTDBStatement.java |  27 +-
 .../apache/iotdb/jdbc/IoTDBResultMetadataTest.java |  24 +-
 .../org/apache/iotdb/db/service/TSServiceImpl.java |  53 +++-
 .../java/org/apache/iotdb/sparkdb/SQLConstant.java |   1 -
 .../scala/org/apache/iotdb/sparkdb/Converter.scala |  13 +-
 .../scala/org/apache/iotdb/sparkdb/IoTDBTest.scala |  63 +++-
 10 files changed, 330 insertions(+), 280 deletions(-)

diff --git a/client/src/main/java/org/apache/iotdb/client/AbstractClient.java b/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
index eb0dabd..a7522a4 100644
--- a/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
+++ b/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
@@ -39,12 +39,11 @@ import org.apache.commons.cli.Options;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.iotdb.exception.ArgsErrorException;
-import org.apache.iotdb.tool.ImportCsv;
 import org.apache.iotdb.jdbc.IoTDBConnection;
-import org.apache.iotdb.jdbc.IoTDBDatabaseMetadata;
 import org.apache.iotdb.jdbc.IoTDBMetadataResultSet;
 import org.apache.iotdb.jdbc.IoTDBQueryResultSet;
 import org.apache.iotdb.service.rpc.thrift.ServerProperties;
+import org.apache.iotdb.tool.ImportCsv;
 import org.apache.thrift.TException;
 
 public abstract class AbstractClient {
@@ -194,12 +193,9 @@ public abstract class AbstractClient {
     int colCount = resultSetMetaData.getColumnCount();
 
     boolean isShow = res instanceof IoTDBMetadataResultSet;
-    if (!isShow && resultSetMetaData.getColumnTypeName(0) != null) {
-      printTimestamp = !res.getMetaData().getColumnTypeName(0)
-          .equalsIgnoreCase(NEED_NOT_TO_PRINT_TIMESTAMP);
-    }
+
     if (res instanceof IoTDBQueryResultSet) {
-      printTimestamp = printTimestamp && !((IoTDBQueryResultSet) res).isIgnoreTimeStamp();
+      printTimestamp = !((IoTDBQueryResultSet) res).isIgnoreTimeStamp();
     }
 
     // Output values
@@ -582,7 +578,7 @@ public abstract class AbstractClient {
         + "                                           \n");
   }
 
-  static void echoStarting(){
+  static void echoStarting() {
     println("---------------------");
     println("Starting IoTDB Client");
     println("---------------------");
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/Constant.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/Constant.java
index 0ae18cb..34df3a3 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/Constant.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/Constant.java
@@ -50,4 +50,6 @@ public class Constant {
   public static final String COUNT_TIMESERIES = "cntts";
   public static final String COUNT_NODE_TIMESERIES = "cnttsbg";
   public static final String COUNT_NODES = "cntnode";
+
+  public static final String METHOD_NOT_SUPPORTED = "Method not supported";
 }
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java
index 012c766..c63413e 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBQueryResultSet.java
@@ -48,7 +48,13 @@ import java.util.List;
 import java.util.Map;
 import org.apache.iotdb.rpc.IoTDBRPCException;
 import org.apache.iotdb.rpc.RpcUtils;
-import org.apache.iotdb.service.rpc.thrift.*;
+import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq;
+import org.apache.iotdb.service.rpc.thrift.TSFetchResultsReq;
+import org.apache.iotdb.service.rpc.thrift.TSFetchResultsResp;
+import org.apache.iotdb.service.rpc.thrift.TSIService;
+import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
+import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
+import org.apache.iotdb.service.rpc.thrift.TSRPCResp;
 import org.apache.iotdb.tsfile.read.common.Field;
 import org.apache.iotdb.tsfile.read.common.RowRecord;
 import org.apache.thrift.TException;
@@ -57,14 +63,12 @@ import org.slf4j.LoggerFactory;
 public class IoTDBQueryResultSet implements ResultSet {
 
   private static final org.slf4j.Logger logger = LoggerFactory.getLogger(IoTDBQueryResultSet.class);
-  private static final String METHOD_NOT_SUPPORTED = "Method not supported";
   private final String TIMESTAMP_STR = "Time";
   private static final String limitStr = "LIMIT";
   private static final String offsetStr = "OFFSET";
   private Statement statement = null;
   private String sql;
   private SQLWarning warningChain = null;
-  private boolean wasNull = false;
   private boolean isClosed = false;
   private TSIService.Iface client = null;
   private TSOperationHandle operationHandle = null;
@@ -77,11 +81,13 @@ public class IoTDBQueryResultSet implements ResultSet {
   private int maxRows; // defined in TsfileStatement
   private int fetchSize;
   private boolean emptyResultSet = false;
-  private String operationType;
+
   // 0 means it is not constrained in sql
   private int rowsLimit = 0;
+
   // 0 means it is not constrained in sql, or the offset position has been reached
   private int rowsOffset = 0;
+
   private long queryId;
   private boolean ignoreTimeStamp = false;
 
@@ -102,24 +108,18 @@ public class IoTDBQueryResultSet implements ResultSet {
     // do nothing
   }
 
-  public IoTDBQueryResultSet(Statement statement, List<String> columnName, TSIService.Iface client,
-      TSOperationHandle operationHandle,
-      String sql, String aggregations,
-      List<String> columnTypeList, long queryId) throws SQLException {
+  public IoTDBQueryResultSet(Statement statement, List<String> columnName,
+      List<String> columnTypeList, boolean ignoreTimeStamp, TSIService.Iface client,
+      TSOperationHandle operationHandle, String sql, long queryId)
+      throws SQLException {
     this.statement = statement;
     this.maxRows = statement.getMaxRows();
     this.fetchSize = statement.getFetchSize();
-    this.client = client;
-    this.operationHandle = operationHandle;
-    this.sql = sql;
-    this.operationType = aggregations;
-    this.columnTypeList = columnTypeList;
 
     this.columnInfoList = new ArrayList<>();
     this.columnInfoList.add(TIMESTAMP_STR);
     this.columnInfoMap = new HashMap<>();
     this.columnInfoMap.put(TIMESTAMP_STR, 1);
-    this.queryId = queryId;
     int index = 2;
     for (String name : columnName) {
       columnInfoList.add(name);
@@ -128,8 +128,14 @@ public class IoTDBQueryResultSet implements ResultSet {
       }
     }
 
-    maxRowsOrRowsLimit = maxRows;
+    this.columnTypeList = columnTypeList;
+    this.ignoreTimeStamp = ignoreTimeStamp;
+    this.client = client;
+    this.operationHandle = operationHandle;
+    this.sql = sql;
+    this.queryId = queryId;
 
+    maxRowsOrRowsLimit = maxRows;
     // parse the LIMIT&OFFSET parameters from sql
     String[] splited = sql.toUpperCase().split("\\s+");
     List<String> arraySplited = Arrays.asList(splited);
@@ -154,6 +160,7 @@ public class IoTDBQueryResultSet implements ResultSet {
           rowsOffset = Integer.parseInt(splited[posOffset + 1]);
         }
       }
+
     } catch (NumberFormatException e) {
       throw new IoTDBSQLException("Out of range: LIMIT&SLIMIT parameter should be Int32.");
     }
@@ -161,37 +168,37 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public boolean isWrapperFor(Class<?> iface) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public <T> T unwrap(Class<T> iface) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean absolute(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void afterLast() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void beforeFirst() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void cancelRowUpdates() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void clearWarnings() throws SQLException {
-    warningChain = null;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -222,7 +229,7 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public void deleteRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -232,27 +239,27 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public boolean first() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Array getArray(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Array getArray(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public InputStream getAsciiStream(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public InputStream getAsciiStream(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -278,22 +285,22 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public InputStream getBinaryStream(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public InputStream getBinaryStream(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Blob getBlob(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Blob getBlob(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -319,46 +326,42 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public byte getByte(int columnIndex) throws SQLException {
-    // TODO Auto-generated method stub
-    return 0;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public byte getByte(String columnName) throws SQLException {
-    // TODO Auto-generated method stub
-    return 0;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public byte[] getBytes(int columnIndex) throws SQLException {
-    // TODO Auto-generated method stub
-    return new byte[0];
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public byte[] getBytes(String columnName) throws SQLException {
-    // TODO Auto-generated method stub
-    return new byte[0];
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Reader getCharacterStream(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Reader getCharacterStream(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Clob getClob(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Clob getClob(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -368,7 +371,7 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public String getCursorName() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -383,12 +386,12 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public Date getDate(int arg0, Calendar arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Date getDate(String arg0, Calendar arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -408,17 +411,17 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public void setFetchDirection(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public int getFetchSize() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void setFetchSize(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -433,7 +436,7 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public int getHoldability() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -458,37 +461,37 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public ResultSetMetaData getMetaData() throws SQLException {
-    return new IoTDBResultMetadata(columnInfoList, operationType, columnTypeList);
+    return new IoTDBResultMetadata(columnInfoList, columnTypeList);
   }
 
   @Override
   public Reader getNCharacterStream(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Reader getNCharacterStream(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public NClob getNClob(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public NClob getNClob(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public String getNString(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public String getNString(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -503,57 +506,57 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public Object getObject(int arg0, Map<String, Class<?>> arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Object getObject(String arg0, Map<String, Class<?>> arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public <T> T getObject(int arg0, Class<T> arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public <T> T getObject(String arg0, Class<T> arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Ref getRef(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Ref getRef(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public int getRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public RowId getRowId(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public RowId getRowId(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public SQLXML getSQLXML(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public SQLXML getSQLXML(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -593,12 +596,12 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public Time getTime(int arg0, Calendar arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Time getTime(String arg0, Calendar arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -613,12 +616,12 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public Timestamp getTimestamp(String arg0, Calendar arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -628,22 +631,22 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public URL getURL(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public URL getURL(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public InputStream getUnicodeStream(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public InputStream getUnicodeStream(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -653,17 +656,17 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public void insertRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isAfterLast() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isBeforeFirst() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -673,27 +676,27 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public boolean isFirst() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isLast() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean last() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void moveToCurrentRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void moveToInsertRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   // the next record rule without constraints
@@ -771,453 +774,453 @@ public class IoTDBQueryResultSet implements ResultSet {
 
   @Override
   public boolean previous() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void refreshRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean relative(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean rowDeleted() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean rowInserted() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean rowUpdated() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateArray(int arg0, Array arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateArray(String arg0, Array arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateAsciiStream(int arg0, InputStream arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateAsciiStream(String arg0, InputStream arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateAsciiStream(int arg0, InputStream arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateAsciiStream(String arg0, InputStream arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateAsciiStream(int arg0, InputStream arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateAsciiStream(String arg0, InputStream arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBigDecimal(int arg0, BigDecimal arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBigDecimal(String arg0, BigDecimal arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBinaryStream(int arg0, InputStream arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBinaryStream(String arg0, InputStream arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBinaryStream(int arg0, InputStream arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBinaryStream(String arg0, InputStream arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBinaryStream(int arg0, InputStream arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBinaryStream(String arg0, InputStream arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBlob(int arg0, Blob arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBlob(String arg0, Blob arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBlob(int arg0, InputStream arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBlob(String arg0, InputStream arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBlob(int arg0, InputStream arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBlob(String arg0, InputStream arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBoolean(int arg0, boolean arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBoolean(String arg0, boolean arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateByte(int arg0, byte arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateByte(String arg0, byte arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBytes(int arg0, byte[] arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateBytes(String arg0, byte[] arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateCharacterStream(int arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateCharacterStream(String arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateCharacterStream(int arg0, Reader arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateCharacterStream(String arg0, Reader arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateCharacterStream(int arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateCharacterStream(String arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateClob(int arg0, Clob arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateClob(String arg0, Clob arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateClob(int arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateClob(String arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateClob(int arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
 
   }
 
   @Override
   public void updateClob(String arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateDate(int arg0, Date arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateDate(String arg0, Date arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateDouble(int arg0, double arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateDouble(String arg0, double arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateFloat(int arg0, float arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateFloat(String arg0, float arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateInt(int arg0, int arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateInt(String arg0, int arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateLong(int arg0, long arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateLong(String arg0, long arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNCharacterStream(int arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNCharacterStream(String arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNCharacterStream(int arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNCharacterStream(String arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNClob(int arg0, NClob arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNClob(String arg0, NClob arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNClob(int arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNClob(String arg0, Reader arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNClob(int arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNClob(String arg0, Reader arg1, long arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNString(int arg0, String arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNString(String arg0, String arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNull(int arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateNull(String arg0) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateObject(int arg0, Object arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateObject(String arg0, Object arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateObject(int arg0, Object arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateObject(String arg0, Object arg1, int arg2) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateRef(int arg0, Ref arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateRef(String arg0, Ref arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateRow() throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateRowId(int arg0, RowId arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateRowId(String arg0, RowId arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateSQLXML(String arg0, SQLXML arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateShort(int arg0, short arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateShort(String arg0, short arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateString(int arg0, String arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateString(String arg0, String arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateTime(int arg0, Time arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateTime(String arg0, Time arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateTimestamp(int arg0, Timestamp arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public void updateTimestamp(String arg0, Timestamp arg1) throws SQLException {
-    throw new SQLException(METHOD_NOT_SUPPORTED);
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean wasNull() throws SQLException {
-    return wasNull;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   private void checkRecord() throws SQLException {
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBResultMetadata.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBResultMetadata.java
index 03652c7..189ceaf 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBResultMetadata.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBResultMetadata.java
@@ -26,41 +26,34 @@ import java.util.List;
 public class IoTDBResultMetadata implements ResultSetMetaData {
 
   private List<String> columnInfoList;
-  private String operationType;
   private List<String> columnTypeList;
 
   /**
    * Constructor of IoTDBResultMetadata.
    */
-  public IoTDBResultMetadata(List<String> columnInfoList, String operationType,
-      List<String> columnTypeList) {
+  public IoTDBResultMetadata(List<String> columnInfoList, List<String> columnTypeList) {
     this.columnInfoList = columnInfoList;
-    this.operationType = operationType;
     this.columnTypeList = columnTypeList;
   }
 
   @Override
   public boolean isWrapperFor(Class<?> arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public <T> T unwrap(Class<T> arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return null;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public String getCatalogName(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return null;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public String getColumnClassName(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return null;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -73,8 +66,7 @@ public class IoTDBResultMetadata implements ResultSetMetaData {
 
   @Override
   public int getColumnDisplaySize(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return 0;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
@@ -102,7 +94,6 @@ public class IoTDBResultMetadata implements ResultSetMetaData {
 
   @Override
   public int getColumnType(int column) throws SQLException {
-    // TODO Auto-generated method stub
     checkColumnIndex(column);
     if (column == 1) {
       return Types.TIMESTAMP;
@@ -130,85 +121,72 @@ public class IoTDBResultMetadata implements ResultSetMetaData {
 
   @Override
   public String getColumnTypeName(int arg0) throws SQLException {
-    return operationType;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public int getPrecision(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return 0;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public int getScale(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return 0;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public String getSchemaName(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return null;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public String getTableName(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return null;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isAutoIncrement(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isCaseSensitive(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isCurrency(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isDefinitelyWritable(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public int isNullable(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return 0;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isReadOnly(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isSearchable(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isSigned(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
   @Override
   public boolean isWritable(int arg0) throws SQLException {
-    // TODO Auto-generated method stub
-    return false;
+    throw new SQLException(Constant.METHOD_NOT_SUPPORTED);
   }
 
 }
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index 35a3bf2..d89c5eb 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -30,11 +30,19 @@ import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
-
 import org.apache.iotdb.rpc.IoTDBRPCException;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.TSStatusType;
-import org.apache.iotdb.service.rpc.thrift.*;
+import org.apache.iotdb.service.rpc.thrift.TSCancelOperationReq;
+import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementResp;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
+import org.apache.iotdb.service.rpc.thrift.TSIService;
+import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
+import org.apache.iotdb.service.rpc.thrift.TSRPCResp;
+import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
 import org.apache.thrift.TException;
 
 public class IoTDBStatement implements Statement {
@@ -283,12 +291,9 @@ public class IoTDBStatement implements Statement {
         throw new IoTDBSQLException(e.getMessage());
       }
       if (execResp.getOperationHandle().hasResultSet) {
-        IoTDBQueryResultSet resSet = new IoTDBQueryResultSet(this,
-            execResp.getColumns(), client,
-            operationHandle, sql, execResp.getOperationType(),
-            execResp.getDataTypeList(), queryId.getAndIncrement());
-        resSet.setIgnoreTimeStamp(execResp.ignoreTimeStamp);
-        this.resultSet = resSet;
+        this.resultSet = new IoTDBQueryResultSet(this, execResp.getColumns(),
+            execResp.getDataTypeList(), execResp.ignoreTimeStamp, client, operationHandle, sql,
+            queryId.getAndIncrement());
         return true;
       }
       return false;
@@ -386,11 +391,9 @@ public class IoTDBStatement implements Statement {
     } catch (IoTDBRPCException e) {
       throw new IoTDBSQLException(e.getMessage());
     }
-    IoTDBQueryResultSet resSet = new IoTDBQueryResultSet(this, execResp.getColumns(), client,
-        operationHandle, sql, execResp.getOperationType(), execResp.getDataTypeList(),
+    this.resultSet = new IoTDBQueryResultSet(this, execResp.getColumns(),
+        execResp.getDataTypeList(), execResp.ignoreTimeStamp, client, operationHandle, sql,
         queryId.getAndIncrement());
-    resSet.setIgnoreTimeStamp(execResp.ignoreTimeStamp);
-    this.resultSet = resSet;
     return resultSet;
   }
 
diff --git a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
index 2796ea5..74113d5 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
@@ -43,7 +43,7 @@ public class IoTDBResultMetadataTest {
 
   @Test
   public void testGetColumnCount() throws SQLException {
-    metadata = new IoTDBResultMetadata(null, null, null);
+    metadata = new IoTDBResultMetadata(null, null);
     boolean flag = false;
     try {
       metadata.getColumnCount();
@@ -55,7 +55,7 @@ public class IoTDBResultMetadataTest {
     List<String> columnInfoList = new ArrayList<>();
     flag = false;
     try {
-      metadata = new IoTDBResultMetadata(columnInfoList, null, null);
+      metadata = new IoTDBResultMetadata(columnInfoList, null);
       metadata.getColumnCount();
     } catch (Exception e) {
       flag = true;
@@ -68,7 +68,7 @@ public class IoTDBResultMetadataTest {
 
   @Test
   public void testGetColumnName() throws SQLException {
-    metadata = new IoTDBResultMetadata(null, null, null);
+    metadata = new IoTDBResultMetadata(null, null);
     boolean flag = false;
     try {
       metadata.getColumnName(1);
@@ -78,7 +78,7 @@ public class IoTDBResultMetadataTest {
     assertEquals(flag, true);
 
     List<String> columnInfoList = new ArrayList<>();
-    metadata = new IoTDBResultMetadata(columnInfoList, null, null);
+    metadata = new IoTDBResultMetadata(columnInfoList, null);
     flag = false;
     try {
       metadata.getColumnName(1);
@@ -88,7 +88,7 @@ public class IoTDBResultMetadataTest {
     assertEquals(flag, true);
 
     String[] colums = {"root.a.b.c1", "root.a.b.c2", "root.a.b.c3"};
-    metadata = new IoTDBResultMetadata(Arrays.asList(colums), null, null);
+    metadata = new IoTDBResultMetadata(Arrays.asList(colums), null);
     flag = false;
     try {
       metadata.getColumnName(colums.length + 1);
@@ -113,7 +113,7 @@ public class IoTDBResultMetadataTest {
 
   @Test
   public void testGetColumnType() throws SQLException {
-    metadata = new IoTDBResultMetadata(null, null, null);
+    metadata = new IoTDBResultMetadata(null, null);
     boolean flag = false;
     try {
       metadata.getColumnType(1);
@@ -123,7 +123,7 @@ public class IoTDBResultMetadataTest {
     assertEquals(flag, true);
 
     List<String> columnInfoList = new ArrayList<>();
-    metadata = new IoTDBResultMetadata(columnInfoList, null, null);
+    metadata = new IoTDBResultMetadata(columnInfoList, null);
     flag = false;
     try {
       metadata.getColumnType(1);
@@ -138,7 +138,7 @@ public class IoTDBResultMetadataTest {
     String[] typesString = {"BOOLEAN", "INT32", "INT64", "FLOAT", "DOUBLE", "TEXT"};
     int[] types = {Types.BOOLEAN, Types.INTEGER, Types.BIGINT, Types.FLOAT, Types.DOUBLE,
         Types.VARCHAR};
-    metadata = new IoTDBResultMetadata(Arrays.asList(columns), null, Arrays.asList(typesString));
+    metadata = new IoTDBResultMetadata(Arrays.asList(columns), Arrays.asList(typesString));
     flag = false;
     try {
       metadata.getColumnType(columns.length + 1);
@@ -160,12 +160,4 @@ public class IoTDBResultMetadataTest {
       assertEquals(metadata.getColumnType(i + 1), types[i - 1]);
     }
   }
-
-  @Test
-  public void testGetColumnTypeName() throws SQLException {
-    String operationType = "sum";
-    metadata = new IoTDBResultMetadata(null, operationType, null);
-    assertEquals(metadata.getColumnTypeName(1), operationType);
-  }
-
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 130362e..ee744e2 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -18,14 +18,21 @@
  */
 package org.apache.iotdb.db.service;
 
-import static org.apache.iotdb.db.conf.IoTDBConstant.*;
+import static org.apache.iotdb.db.conf.IoTDBConstant.PRIVILEGE;
+import static org.apache.iotdb.db.conf.IoTDBConstant.ROLE;
+import static org.apache.iotdb.db.conf.IoTDBConstant.USER;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.time.ZoneId;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.regex.Pattern;
@@ -42,13 +49,19 @@ import org.apache.iotdb.db.cost.statistic.Measurement;
 import org.apache.iotdb.db.cost.statistic.Operation;
 import org.apache.iotdb.db.engine.StorageEngine;
 import org.apache.iotdb.db.engine.flush.pool.FlushTaskPoolManager;
-import org.apache.iotdb.db.exception.*;
+import org.apache.iotdb.db.exception.ArgsErrorException;
+import org.apache.iotdb.db.exception.MetadataErrorException;
+import org.apache.iotdb.db.exception.PathErrorException;
+import org.apache.iotdb.db.exception.ProcessorException;
+import org.apache.iotdb.db.exception.QueryInBatchStmtException;
+import org.apache.iotdb.db.exception.StorageEngineException;
 import org.apache.iotdb.db.exception.qp.IllegalASTFormatException;
 import org.apache.iotdb.db.exception.qp.QueryProcessorException;
 import org.apache.iotdb.db.metadata.MManager;
 import org.apache.iotdb.db.metadata.Metadata;
 import org.apache.iotdb.db.qp.QueryProcessor;
 import org.apache.iotdb.db.qp.executor.QueryProcessExecutor;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
 import org.apache.iotdb.db.qp.logical.sys.MetadataOperator;
 import org.apache.iotdb.db.qp.physical.PhysicalPlan;
 import org.apache.iotdb.db.qp.physical.crud.BatchInsertPlan;
@@ -62,7 +75,36 @@ import org.apache.iotdb.db.tools.watermark.GroupedLSBWatermarkEncoder;
 import org.apache.iotdb.db.tools.watermark.WatermarkEncoder;
 import org.apache.iotdb.db.utils.QueryDataSetUtils;
 import org.apache.iotdb.rpc.TSStatusType;
-import org.apache.iotdb.service.rpc.thrift.*;
+import org.apache.iotdb.service.rpc.thrift.ServerProperties;
+import org.apache.iotdb.service.rpc.thrift.TSBatchInsertionReq;
+import org.apache.iotdb.service.rpc.thrift.TSCancelOperationReq;
+import org.apache.iotdb.service.rpc.thrift.TSCloseOperationReq;
+import org.apache.iotdb.service.rpc.thrift.TSCloseSessionReq;
+import org.apache.iotdb.service.rpc.thrift.TSCreateTimeseriesReq;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementReq;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteBatchStatementResp;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementReq;
+import org.apache.iotdb.service.rpc.thrift.TSExecuteStatementResp;
+import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataReq;
+import org.apache.iotdb.service.rpc.thrift.TSFetchMetadataResp;
+import org.apache.iotdb.service.rpc.thrift.TSFetchResultsReq;
+import org.apache.iotdb.service.rpc.thrift.TSFetchResultsResp;
+import org.apache.iotdb.service.rpc.thrift.TSGetTimeZoneResp;
+import org.apache.iotdb.service.rpc.thrift.TSHandleIdentifier;
+import org.apache.iotdb.service.rpc.thrift.TSIService;
+import org.apache.iotdb.service.rpc.thrift.TSInsertReq;
+import org.apache.iotdb.service.rpc.thrift.TSInsertionReq;
+import org.apache.iotdb.service.rpc.thrift.TSOpenSessionReq;
+import org.apache.iotdb.service.rpc.thrift.TSOpenSessionResp;
+import org.apache.iotdb.service.rpc.thrift.TSOperationHandle;
+import org.apache.iotdb.service.rpc.thrift.TSProtocolVersion;
+import org.apache.iotdb.service.rpc.thrift.TSQueryDataSet;
+import org.apache.iotdb.service.rpc.thrift.TSRPCResp;
+import org.apache.iotdb.service.rpc.thrift.TSSetStorageGroupReq;
+import org.apache.iotdb.service.rpc.thrift.TSSetTimeZoneReq;
+import org.apache.iotdb.service.rpc.thrift.TS_SessionHandle;
+import org.apache.iotdb.service.rpc.thrift.TS_Status;
+import org.apache.iotdb.service.rpc.thrift.TS_StatusType;
 import org.apache.iotdb.tsfile.common.constant.StatisticConstant;
 import org.apache.iotdb.tsfile.exception.filter.QueryFilterOptimizationException;
 import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
@@ -599,6 +641,9 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       } else {
         resp = executeAuthQuery(plan, columns);
       }
+      if (plan.getOperatorType() == OperatorType.AGGREGATION) {
+        resp.setIgnoreTimeStamp(true);
+      } // else default ignoreTimeStamp is false
       resp.setColumns(columns);
       resp.setDataTypeList(queryColumnsType(columns));
       resp.setOperationType(plan.getOperatorType().toString());
diff --git a/spark-iotdb-connector/src/main/java/org/apache/iotdb/sparkdb/SQLConstant.java b/spark-iotdb-connector/src/main/java/org/apache/iotdb/sparkdb/SQLConstant.java
index 466df21..a69bba5 100644
--- a/spark-iotdb-connector/src/main/java/org/apache/iotdb/sparkdb/SQLConstant.java
+++ b/spark-iotdb-connector/src/main/java/org/apache/iotdb/sparkdb/SQLConstant.java
@@ -23,7 +23,6 @@ package org.apache.iotdb.sparkdb;
  */
 public class SQLConstant {
 
-  public static final String NEED_NOT_TO_PRINT_TIMESTAMP = "AGGREGATION";
   public static final String RESERVED_TIME = "time";
   public static final String TIMESTAMP_STR = "Time";
   public static final String NULL_STR = "null";
diff --git a/spark-iotdb-connector/src/main/scala/org/apache/iotdb/sparkdb/Converter.scala b/spark-iotdb-connector/src/main/scala/org/apache/iotdb/sparkdb/Converter.scala
index 9548976..80567cc 100644
--- a/spark-iotdb-connector/src/main/scala/org/apache/iotdb/sparkdb/Converter.scala
+++ b/spark-iotdb-connector/src/main/scala/org/apache/iotdb/sparkdb/Converter.scala
@@ -18,11 +18,11 @@
   */
 package org.apache.iotdb.sparkdb
 
-import java.sql._
+import java.sql.{Statement, _}
 
+import org.apache.iotdb.jdbc.IoTDBQueryResultSet
 import org.apache.spark.sql.types._
 import org.slf4j.LoggerFactory
-import java.sql.Statement
 
 import scala.collection.mutable.ListBuffer
 
@@ -58,15 +58,12 @@ object Converter {
       val resultSet: ResultSet = sqlStatement.getResultSet
       val resultSetMetaData: ResultSetMetaData = resultSet.getMetaData
 
-      if (resultSetMetaData.getColumnTypeName(0) != null) {
-        val printTimestamp: Boolean = !resultSetMetaData.getColumnTypeName(0).toUpperCase().equals(SQLConstant.NEED_NOT_TO_PRINT_TIMESTAMP)
-        if (printTimestamp) {
-          fields += StructField(SQLConstant.TIMESTAMP_STR, LongType, nullable = false)
-        }
+      val printTimestamp = !resultSet.asInstanceOf[IoTDBQueryResultSet].isIgnoreTimeStamp
+      if (printTimestamp) {
+        fields += StructField(SQLConstant.TIMESTAMP_STR, LongType, nullable = false)
       }
 
       val colCount = resultSetMetaData.getColumnCount
-
       for (i <- 2 to colCount) {
         fields += StructField(resultSetMetaData.getColumnLabel(i), resultSetMetaData.getColumnType(i) match {
           case Types.BOOLEAN => BooleanType
diff --git a/spark-iotdb-connector/src/test/scala/org/apache/iotdb/sparkdb/IoTDBTest.scala b/spark-iotdb-connector/src/test/scala/org/apache/iotdb/sparkdb/IoTDBTest.scala
index e4e9eaa..48418fb 100644
--- a/spark-iotdb-connector/src/test/scala/org/apache/iotdb/sparkdb/IoTDBTest.scala
+++ b/spark-iotdb-connector/src/test/scala/org/apache/iotdb/sparkdb/IoTDBTest.scala
@@ -18,6 +18,8 @@
   */
 package org.apache.iotdb.sparkdb
 
+import java.io.ByteArrayOutputStream
+
 import org.apache.iotdb.db.service.IoTDB
 import org.apache.iotdb.jdbc.Config
 import org.apache.spark.sql.{SQLContext, SparkSession}
@@ -65,51 +67,84 @@ class IoTDBTest extends FunSuite with BeforeAndAfterAll {
   }
 
   test("test show data") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root").load
-    df.printSchema()
-    df.show()
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root").load
     Assert.assertEquals(7505, df.count())
   }
 
   test("test show data with partition") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root").option("lowerBound", 1).option("upperBound", System.nanoTime() / 1000 / 1000).option("numPartition", 10).load
-
-    df.printSchema()
-
-    df.show()
-
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select * from root")
+      .option("lowerBound", 1).option("upperBound", System.nanoTime() / 1000 / 1000)
+      .option("numPartition", 10).load
     Assert.assertEquals(7505, df.count())
   }
 
   test("test filter data") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root where time < 2000 and time > 1000").load
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select * from root where time < 2000 and time > 1000").load
 
     Assert.assertEquals(499, df.count())
   }
 
   test("test filter data with partition") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root where time < 2000 and time > 1000").option("lowerBound", 1).option("upperBound", 10000).option("numPartition", 10).load
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select * from root where time < 2000 and time > 1000")
+      .option("lowerBound", 1)
+      .option("upperBound", 10000).option("numPartition", 10).load
 
     Assert.assertEquals(499, df.count())
   }
 
   test("test transform to narrow") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root where time < 1100 and time > 1000").load
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select * from root where time < 1100 and time > 1000").load
     val narrow_df = Transformer.toNarrowForm(spark, df)
     Assert.assertEquals(198, narrow_df.count())
   }
 
   test("test transform to narrow with partition") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root where time < 1100 and time > 1000").option("lowerBound", 1).option("upperBound", 10000).option("numPartition", 10).load
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select * from root where time < 1100 and time > 1000")
+      .option("lowerBound", 1).option("upperBound", 10000)
+      .option("numPartition", 10).load
     val narrow_df = Transformer.toNarrowForm(spark, df)
     Assert.assertEquals(198, narrow_df.count())
   }
 
   test("test transform back to wide") {
-    val df = spark.read.format("org.apache.iotdb.sparkdb").option("url", "jdbc:iotdb://127.0.0.1:6667/").option("sql", "select * from root where time < 1100 and time > 1000").load
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select * from root where time < 1100 and time > 1000").load
     val narrow_df = Transformer.toNarrowForm(spark, df)
     val wide_df = Transformer.toWideForm(spark, narrow_df)
     Assert.assertEquals(99, wide_df.count())
   }
+
+  test("test aggregate sql") {
+    val df = spark.read.format("org.apache.iotdb.sparkdb")
+      .option("url", "jdbc:iotdb://127.0.0.1:6667/")
+      .option("sql", "select count(d0.s0),count(d0.s1) from root.vehicle").load
+
+    val outCapture = new ByteArrayOutputStream
+    Console.withOut(outCapture) {
+      df.show(df.count.toInt, false)
+    }
+    val actual = outCapture.toByteArray.map(_.toChar)
+
+    val expect =
+      "+-------------------------+-------------------------+\n" +
+        "|count(root.vehicle.d0.s0)|count(root.vehicle.d0.s1)|\n" +
+        "+-------------------------+-------------------------+\n" +
+        "|7500                     |7500                     |\n" +
+        "+-------------------------+-------------------------+\n"
+
+    Assert.assertArrayEquals(expect.toCharArray, actual.dropRight(2))
+  }
 }