diff --git a/docs/Documentation-CHN/UserGuide/5-Operation Manual/4-SQL Reference.md b/docs/Documentation-CHN/UserGuide/5-Operation Manual/4-SQL Reference.md index f65d25d190c78d8bb652aa7410895a147fc7aa67..396dd2c39472150808bedf4f1061051e2bff1c48 100644 --- a/docs/Documentation-CHN/UserGuide/5-Operation Manual/4-SQL Reference.md +++ b/docs/Documentation-CHN/UserGuide/5-Operation Manual/4-SQL Reference.md @@ -22,6 +22,19 @@ # 第5章 IoTDB操作指南 ## SQL 参考文档 +### 显示版本号 + +```sql +show version +``` + +``` ++---------------------------------------------------------------------------+ +| 0.9.0-SNAPSHOT| ++---------------------------------------------------------------------------+ +It costs 0.001s +``` + ### Schema语句 * 设置存储组 diff --git a/docs/Documentation/UserGuide/5-Operation Manual/4-SQL Reference.md b/docs/Documentation/UserGuide/5-Operation Manual/4-SQL Reference.md index e4e361045cad9f75b83e2450caca67bc3857c81f..28e0d0e702a301cb00df854dfa015985bb6fc2a5 100644 --- a/docs/Documentation/UserGuide/5-Operation Manual/4-SQL Reference.md +++ b/docs/Documentation/UserGuide/5-Operation Manual/4-SQL Reference.md @@ -30,6 +30,18 @@ In this part, we will introduce you IoTDB's Query Language. IoTDB offers you a S All of these statements are write in IoTDB's own syntax, for details about the syntax composition, please check the `Reference` section. +### Show Version + +```sql +show version +``` + +``` ++---------------------------------------------------------------------------+ +| 0.9.0-SNAPSHOT| ++---------------------------------------------------------------------------+ +It costs 0.001s +``` ### Schema Statement 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 15cd761852c85bef67fd2f5704b49b0889af7a52..4b0586d998f6ca31a73133694a7b854f77dabc7f 100644 --- a/jdbc/src/main/java/org/apache/iotdb/jdbc/Constant.java +++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/Constant.java @@ -24,7 +24,7 @@ public class Constant { public static final String GLOBAL_DB_NAME = "IoTDB"; - static final String GLOBAL_DB_VERSION = "0.8.0-SNAPSHOT"; + static final String GLOBAL_VERSION = "VERSION"; public static final String GLOBAL_COLUMN_REQ = "COLUMN"; @@ -47,6 +47,7 @@ public class Constant { public static final String CATALOG_TIMESERIES = "ts"; public static final String CATALOG_STORAGE_GROUP = "sg"; public static final String CATALOG_DEVICES = "devices"; + public static final String CATALOG_VERSION = "version"; static final String COUNT_TIMESERIES = "cntts"; static final String COUNT_NODE_TIMESERIES = "cntnodets"; diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadata.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadata.java index c88aac978793125292b127410f3f81cc2d207e3d..60d4dabf3a24ffa8dedf009226a9298781ab4217 100644 --- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadata.java +++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDatabaseMetadata.java @@ -147,6 +147,20 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData { } catch (TException e) { throw new TException("Connection error when fetching timeseries metadata", e); } + case Constant.CATALOG_VERSION: + req = new TSFetchMetadataReq(Constant.GLOBAL_VERSION); + req.setColumnPath(schemaPattern); + try { + TSFetchMetadataResp resp = client.fetchMetadata(req); + try { + RpcUtils.verifySuccess(resp.getStatus()); + } catch (IoTDBRPCException e) { + throw new IoTDBSQLException(e.getMessage(), resp.getStatus()); + } + return new IoTDBMetadataResultSet(resp.getVersion(), MetadataType.VERSION); + } catch (TException e) { + throw new TException("Connection error when fetching timeseries metadata", e); + } default: throw new SQLException(catalog + " is not supported. Please refer to the user guide" + " for more details."); @@ -335,8 +349,8 @@ public class IoTDBDatabaseMetadata implements DatabaseMetaData { } @Override - public String getDatabaseProductVersion() { - return Constant.GLOBAL_DB_VERSION; + public String getDatabaseProductVersion() throws SQLException { + throw new SQLException(METHOD_NOT_SUPPORTED_STRING); } @Override diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBMetadataResultSet.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBMetadataResultSet.java index c1e319a9232f9fea60c50847e253fff8435e319c..8de848feb2bc1dc3ff937cf2b51f8c8df3065c06 100644 --- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBMetadataResultSet.java +++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBMetadataResultSet.java @@ -42,6 +42,7 @@ public class IoTDBMetadataResultSet extends IoTDBQueryResultSet { private String currentColumn; private String currentStorageGroup; private String currentDevice; + private String currentVersion; private List currentTimeseries; private List timeseriesNumList; private List nodesNumList; @@ -109,6 +110,14 @@ public class IoTDBMetadataResultSet extends IoTDBQueryResultSet { showLabels = new String[]{"column", "count"}; columnItr = nodeTimeseriesNumMap.entrySet().iterator(); break; + case VERSION: + String version = (String) object; + colCount = 1; + showLabels = new String[]{version}; + Set versionSet = new HashSet<>(); + versionSet.add(version); + columnItr = versionSet.iterator(); + break; default: throw new SQLException("TsfileMetadataResultSet constructor is wrongly used."); } @@ -262,6 +271,10 @@ public class IoTDBMetadataResultSet extends IoTDBQueryResultSet { currentNode = (String) pair.getKey(); currentNodeTimeseriesNum = (String) pair.getValue(); break; + case VERSION: + currentVersion = (String) columnItr.next(); + hasNext = false; + break; default: break; } @@ -396,6 +409,6 @@ public class IoTDBMetadataResultSet extends IoTDBQueryResultSet { } public enum MetadataType { - STORAGE_GROUP, TIMESERIES, COLUMN, DEVICES, COUNT_TIMESERIES, COUNT_NODES, COUNT_NODE_TIMESERIES + STORAGE_GROUP, TIMESERIES, COLUMN, DEVICES, COUNT_TIMESERIES, COUNT_NODES, COUNT_NODE_TIMESERIES, VERSION } } 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 cd7b3ddf0fa90ffb3edd6afd105702a5c30cc5de..9d8fce3459aa6dbf671f98bc6e1fa9546321f843 100644 --- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java +++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java @@ -53,6 +53,7 @@ public class IoTDBStatement implements Statement { private static final String COUNT_TIMESERIES_COMMAND_LOWERCASE = "count timeseries"; private static final String COUNT_NODES_COMMAND_LOWERCASE = "count nodes"; private static final String METHOD_NOT_SUPPORTED_STRING = "Method not supported"; + private static final String SHOW_VERSION_COMMAND_LOWERCASE = "show version"; ZoneId zoneId; private ResultSet resultSet = null; @@ -287,6 +288,10 @@ public class IoTDBStatement implements Statement { resultSet = databaseMetaData.getNodes(Constant.COUNT_NODES, path, null, null, level); return true; } + } else if(sqlToLowerCase.equals(SHOW_VERSION_COMMAND_LOWERCASE)) { + IoTDBDatabaseMetadata databaseMetadata = (IoTDBDatabaseMetadata) connection.getMetaData(); + resultSet = databaseMetadata.getColumns(Constant.CATALOG_VERSION, null, null, null); + return true; } else { TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql); TSExecuteStatementResp execResp = client.executeStatement(execReq); diff --git a/server/src/assembly/resources/conf/tsfile-format.properties b/server/src/assembly/resources/conf/tsfile-format.properties deleted file mode 100644 index 2e6efdc4e7a598ddb10319042ba91e4e2fe247bd..0000000000000000000000000000000000000000 --- a/server/src/assembly/resources/conf/tsfile-format.properties +++ /dev/null @@ -1,53 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -group_size_in_byte=134217728 - -# The memory size for each series writer to pack page, default value is 64KB -page_size_in_byte=65536 - -# The maximum number of data points in a page, default 1024*1024 -max_number_of_points_in_page=1048576 - -# Data type configuration -# Data type for input timestamp, TsFile supports INT32 or INT64 -time_series_data_type=INT64 - -# Max size limitation of input string -max_string_length=128 - -# Floating-point precision -float_precision=2 - -# Encoder configuration -# Encoder of time series, TsFile supports TS_2DIFF, PLAIN and RLE(run-length encoding) and default value is TS_2DIFF -time_encoder=TS_2DIFF - -# Encoder of value series. default value is PLAIN. -# For int, long data type, TsFile also supports TS_2DIFF and RLE(run-length encoding). -# For float, double data type, TsFile also supports TS_2DIFF, RLE(run-length encoding) and GORILLA. -# For text data type, TsFile only supports PLAIN. -value_encoder=PLAIN - -# Compression configuration -# Data compression method, TsFile supports UNCOMPRESSED or SNAPPY. Default value is UNCOMPRESSED which means no compression -compressor=UNCOMPRESSED - -# The acceptable error rate of bloom filter, should be in [0.01, 0.1], default is 0.05 -bloom_filter_error_rate=0.05 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 11f1d0b2f3fe8582a2ae8f0d0008db60af93ce62..60700ec07499246395589e79b8c369e87f471a42 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 @@ -346,6 +346,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext { resp.setNodeTimeseriesNum(getNodeTimeseriesNum(getNodesList(req.getColumnPath(), req.getNodeLevel()))); status = new TSStatus(getStatus(TSStatusCode.SUCCESS_STATUS)); break; + case "VERSION": + resp.setVersion(getVersion()); + status = new TSStatus(getStatus(TSStatusCode.SUCCESS_STATUS)); + break; default: status = getStatus(TSStatusCode.FETCH_METADATA_ERROR, req.getType()); break; @@ -384,6 +388,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext { return MManager.getInstance().getAllDevices(); } + private String getVersion() throws SQLException { + return IoTDBConstant.VERSION; + } + private List> getTimeSeriesForPath(String path) throws PathErrorException { return MManager.getInstance().getShowTimeseriesPath(path); diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java index ace6ad667ef9c64aa58ec95e2a9a8d95f874c7a3..c1da2e7fa47faef2bd879cf57d8b4e905b882ccd 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java @@ -27,6 +27,7 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; +import org.apache.iotdb.db.conf.IoTDBConstant; import org.apache.iotdb.db.service.IoTDB; import org.apache.iotdb.db.utils.EnvironmentUtils; import org.apache.iotdb.jdbc.Config; @@ -85,7 +86,7 @@ public class IoTDBMetadataFetchIT { } @Test - public void showTimeseriesTest1() throws ClassNotFoundException, SQLException { + public void showTimeseriesTest() throws ClassNotFoundException, SQLException { Class.forName(Config.JDBC_DRIVER_NAME); try (Connection connection = DriverManager .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root"); @@ -201,6 +202,27 @@ public class IoTDBMetadataFetchIT { } } + @Test + public void showVersion() throws SQLException, ClassNotFoundException { + Class.forName(Config.JDBC_DRIVER_NAME); + try (Connection connection = DriverManager + .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root"); + Statement statement = connection.createStatement()) { + String sql = "show version"; + try { + boolean hasResultSet = statement.execute(sql); + if(hasResultSet) { + try(ResultSet resultSet = statement.getResultSet()) { + ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); + Assert.assertEquals(resultSetMetaData.getColumnLabel(1), IoTDBConstant.VERSION); + } + } + } catch (Exception e) { + fail(e.getMessage()); + } + } + } + /** * get all columns' name under a given seriesPath */ @@ -307,7 +329,7 @@ public class IoTDBMetadataFetchIT { String standard = "Storage Group,\n" + "root.ln.wf01.wt01,\n"; try (ResultSet resultSet = databaseMetaData - .getColumns(Constant.CATALOG_STORAGE_GROUP, null, null, null);) { + .getColumns(Constant.CATALOG_STORAGE_GROUP, null, null, null)) { ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); int colCount = resultSetMetaData.getColumnCount(); StringBuilder resultStr = new StringBuilder(); diff --git a/service-rpc/rpc-changelist.md b/service-rpc/rpc-changelist.md index c66a7c4bdce307e6e45c0f06c6688649e9587338..0ec3c3bc7359f7c088523d6da4a8978fadf22e1b 100644 --- a/service-rpc/rpc-changelist.md +++ b/service-rpc/rpc-changelist.md @@ -53,7 +53,6 @@ Last Updated on October 27th, 2019 by Lei Rui. | Add method TSStatus deleteStorageGroups(1:list\ storageGroup) | Yi Tao | - ## 3. Update | Latest Changes | Related Committers | @@ -72,6 +71,7 @@ Last Updated on October 27th, 2019 by Lei Rui. | Rename some fields in TSFetchMetadataResp: ~~ColumnsList~~ to columnsList, ~~showTimeseriesList~~ to timeseriesList, ~~showStorageGroups~~ to storageGroups | Zesong Sun | | Change struct TSQueryDataSet to eliminate row-wise rpc writing | Lei Rui | | Add optional i32 timeseriesNum in TSFetchMetadataResp | Jack Tsai | +| Add optional string version in TSFetchMetadataResp | Genius_pig | diff --git a/service-rpc/src/main/thrift/rpc.thrift b/service-rpc/src/main/thrift/rpc.thrift index 0e1186fe2e781359ea72e326e7ce218c249eb0f7..826a460f1c988992d5ed74237424053e3d404bd0 100644 --- a/service-rpc/src/main/thrift/rpc.thrift +++ b/service-rpc/src/main/thrift/rpc.thrift @@ -184,6 +184,7 @@ struct TSFetchMetadataResp{ 8: optional set devices 9: optional list nodesList 10: optional map nodeTimeseriesNum + 11: optional string version } struct TSFetchMetadataReq{ diff --git a/tsfile/src/main/resources/tsfile-format.properties.template b/tsfile/src/main/resources/tsfile-format.properties.template deleted file mode 100644 index 0cef513d56a75df78dc508f136df1c05f2a754a5..0000000000000000000000000000000000000000 --- a/tsfile/src/main/resources/tsfile-format.properties.template +++ /dev/null @@ -1,59 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - - -# Memory size threshold for flushing to disk or HDFS, default value is 128MB -group_size_in_byte=134217728 - -# The memory size for each series writer to pack page, default value is 1MB -page_size_in_byte=1048576 - -# The maximum number of data points in a page, defalut 1024*1024 -max_number_of_points_in_page=1048576 - -# The acceptable error rate of bloom filter, should be in [0.01, 0.1] -bloom_filter_error_rate=0.05 - -# Data type configuration - -# Data type for input timestamp, TsFile supports INT32 or INT64 -time_series_data_type=INT64 - -# Max length limitation of input string -max_string_length=128 - -# Floating-point precision -float_precision=2 - -# Encoder configuration - -# Encoder of time series, TsFile supports TS_2DIFF, PLAIN and RLE(run-length encoding) and default value is TS_2DIFF -time_series_encoder=TS_2DIFF - -# Encoder of value series. default value is PLAIN. -# For int, long data type, TsFile also supports TS_2DIFF and RLE(run-length encoding). -# For float, double data type, TsFile also supports TS_2DIFF, RLE(run-length encoding) and GORILLA. -# For text data type, TsFile only supports PLAIN. -value_encoder=PLAIN - -# Compression configuration - -# Data compression method, TsFile supports UNCOMPRESSED or SNAPPY. Default value is UNCOMPRESSED which means no compression -compressor=UNCOMPRESSED -