You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/11/03 03:30:30 UTC
[GitHub] [iotdb] SteveYurongSu commented on a change in pull request #4292: [IOTDB-1775] CAST conversion function
SteveYurongSu commented on a change in pull request #4292:
URL: https://github.com/apache/iotdb/pull/4292#discussion_r741597078
##########
File path: docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
##########
@@ -459,7 +459,41 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from
Total line number = 5
It costs 0.005s
```
-
+#### Data Type Conversion Function
+The IoTDB currently supports 6 data types, including INT32, INT64 ,FLOAT, DOUBLE, BOOLEAN, TEXT. When we query or evaluate data, we may need to convert data types, such as TEXT to INT32, or improve the accuracy of the data, such as FLOAT to DOUBLE. Therefore, IoTDB supports the use of cast functions to convert data types.
+##### Notes
+1.The value of type BOOLEAN is `true`, when data is converted to BOOLEAN if INT32 and INT64 are not 0, FLOAT and DOUBLE are not 0.0, TEXT is not empty string or "false", otherwise `false`.
+2.The value of type INT32, INT64, FLOAT, DOUBLE are 1 or 1.0 and TEXT is "true", when BOOLEAN data is true, otherwise 0, 0.0 or "false".
+##### Syntax
+Example data:
+```
+IoTDB> select text from root.test;
++-----------------------------+--------------+
+| Time|root.test.text|
++-----------------------------+--------------+
+|1970-01-01T08:00:00.001+08:00| 1.1|
+|1970-01-01T08:00:00.002+08:00| 1|
+|1970-01-01T08:00:00.003+08:00| hello world|
+|1970-01-01T08:00:00.004+08:00| false|
++-----------------------------+--------------+
+```
+SQL:
+```
+select cast(text,'type'='BOOLEAN') from root.test;
Review comment:
Please introduce 'type'
##########
File path: server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
##########
@@ -364,4 +364,38 @@ public void testConstantTimeSeriesGeneratingFunctions() {
fail(throwable.getMessage());
}
}
+
+ @Test
+ public void testConversionFunction() {
Review comment:
Add some tests in Session
##########
File path: docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
##########
@@ -459,7 +459,41 @@ select s1, s2, const(s1, 'value'='1024', 'type'='INT64'), pi(s2), e(s1, s2) from
Total line number = 5
It costs 0.005s
```
-
+#### Data Type Conversion Function
+The IoTDB currently supports 6 data types, including INT32, INT64 ,FLOAT, DOUBLE, BOOLEAN, TEXT. When we query or evaluate data, we may need to convert data types, such as TEXT to INT32, or improve the accuracy of the data, such as FLOAT to DOUBLE. Therefore, IoTDB supports the use of cast functions to convert data types.
+##### Notes
+1.The value of type BOOLEAN is `true`, when data is converted to BOOLEAN if INT32 and INT64 are not 0, FLOAT and DOUBLE are not 0.0, TEXT is not empty string or "false", otherwise `false`.
+2.The value of type INT32, INT64, FLOAT, DOUBLE are 1 or 1.0 and TEXT is "true", when BOOLEAN data is true, otherwise 0, 0.0 or "false".
Review comment:
Introduce more about the binary cast process.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org