From 53d77c60498efafd26fd1e0231be3d137ea66e27 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Fri, 7 Feb 2025 11:12:48 +0800 Subject: [PATCH 1/4] fix: cast double --- include/common/ttypes.h | 10 +++++----- tests/army/query/function/cast.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/common/ttypes.h b/include/common/ttypes.h index c50ce7ba73..675f774566 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -239,21 +239,21 @@ typedef struct { snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \ break; \ case TSDB_DATA_TYPE_FLOAT: { \ - int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%.7f", *(float *)(_input)); \ if (n >= (_outputBytes)) { \ n = snprintf(_output, (int32_t)(_outputBytes), "%.7e", *(float *)(_input)); \ if (n >= (_outputBytes)) { \ - snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + snprintf(_output, (int32_t)(_outputBytes), "%e", *(float *)(_input)); \ } \ } \ break; \ } \ case TSDB_DATA_TYPE_DOUBLE: { \ - int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%.15f", *(double *)(_input)); \ if (n >= (_outputBytes)) { \ - snprintf(_output, (int32_t)(_outputBytes), "%.15e", *(double *)(_input)); \ + n = snprintf(_output, (int32_t)(_outputBytes), "%.15e", *(double *)(_input)); \ if (n >= (_outputBytes)) { \ - snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + snprintf(_output, (int32_t)(_outputBytes), "%e", *(double *)(_input)); \ } \ } \ break; \ diff --git a/tests/army/query/function/cast.py b/tests/army/query/function/cast.py index af72f1de2c..2765250d93 100644 --- a/tests/army/query/function/cast.py +++ b/tests/army/query/function/cast.py @@ -540,6 +540,18 @@ class TDTestCase(TBase): tdSql.query(f"select cast({add1}+{test_str} as nchar(2)) re;") tdSql.checkData(0, 0, "12") + + def ts5972(self): + tdSql.execute("CREATE DATABASE IF NOT EXISTS ts5972;") + tdSql.execute("DROP TABLE IF EXISTS ts5972.t1;") + tdSql.execute("DROP TABLE IF EXISTS ts5972.t1;") + tdSql.execute("CREATE TABLE ts5972.t1(time TIMESTAMP, c0 DOUBLE);") + tdSql.execute("INSERT INTO ts5972.t1(time, c0) VALUES (1641024000000, 0.018518518518519), (1641024005000, 0.015151515151515), (1641024010000, 0.1234567891012345);") + tdSql.query("SELECT c0, CAST(c0 AS BINARY(50)) FROM ts5972.t1 WHERE CAST(c0 AS BINARY(50)) != c0;") + tdSql.checkRows(0) + tdSql.query("SELECT c0, CAST(c0 AS BINARY(50)) FROM ts5972.t1 WHERE CAST(c0 AS BINARY(50)) == c0;") + tdSql.checkRows(3) + def cast_without_from(self): self.cast_from_int_to_other() @@ -556,6 +568,7 @@ class TDTestCase(TBase): def run(self): # 'from table' case see system-test/2-query/cast.py self.cast_without_from() + self.ts5972() tdLog.success(f"{__file__} successfully executed") From edd5754f5643e4ab185e79a58ddbc4566a283a7e Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Mon, 10 Feb 2025 18:02:28 +0800 Subject: [PATCH 2/4] test case --- include/common/ttypes.h | 86 ++++++++----------- tests/army/query/function/cast.py | 3 +- tests/army/query/test_case_when.py | 10 ++- tests/pytest/util/sql.py | 23 +++++ tests/script/tsim/scalar/caseWhen.sim | 22 ++--- .../script/tsim/stream/streamTwaInterpFwc.sim | 2 +- tests/system-test/2-query/cast.py | 24 +++--- 7 files changed, 92 insertions(+), 78 deletions(-) diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 675f774566..d0cddd87a9 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -216,55 +216,43 @@ typedef struct { } \ } while (0) -#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \ - do { \ - switch (_inputType) { \ - case TSDB_DATA_TYPE_TINYINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input)); \ - break; \ - case TSDB_DATA_TYPE_UTINYINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input)); \ - break; \ - case TSDB_DATA_TYPE_SMALLINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input)); \ - break; \ - case TSDB_DATA_TYPE_USMALLINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input)); \ - break; \ - case TSDB_DATA_TYPE_TIMESTAMP: \ - case TSDB_DATA_TYPE_BIGINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input)); \ - break; \ - case TSDB_DATA_TYPE_UBIGINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \ - break; \ - case TSDB_DATA_TYPE_FLOAT: { \ - int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%.7f", *(float *)(_input)); \ - if (n >= (_outputBytes)) { \ - n = snprintf(_output, (int32_t)(_outputBytes), "%.7e", *(float *)(_input)); \ - if (n >= (_outputBytes)) { \ - snprintf(_output, (int32_t)(_outputBytes), "%e", *(float *)(_input)); \ - } \ - } \ - break; \ - } \ - case TSDB_DATA_TYPE_DOUBLE: { \ - int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%.15f", *(double *)(_input)); \ - if (n >= (_outputBytes)) { \ - n = snprintf(_output, (int32_t)(_outputBytes), "%.15e", *(double *)(_input)); \ - if (n >= (_outputBytes)) { \ - snprintf(_output, (int32_t)(_outputBytes), "%e", *(double *)(_input)); \ - } \ - } \ - break; \ - } \ - case TSDB_DATA_TYPE_UINT: \ - snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \ - break; \ - default: \ - snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input)); \ - break; \ - } \ +#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \ + do { \ + switch (_inputType) { \ + case TSDB_DATA_TYPE_TINYINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_TIMESTAMP: \ + case TSDB_DATA_TYPE_BIGINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_FLOAT: { \ + snprintf(_output, (int32_t)(_outputBytes), "%.*g", FLT_DIG, *(float *)(_input)); \ + break; \ + } \ + case TSDB_DATA_TYPE_DOUBLE: { \ + snprintf(_output, (int32_t)(_outputBytes), "%.*g", DBL_DIG, *(double *)(_input)); \ + break; \ + } \ + case TSDB_DATA_TYPE_UINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \ + break; \ + default: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input)); \ + break; \ + } \ } while (0) // TODO: use varchar(0) to represent NULL type diff --git a/tests/army/query/function/cast.py b/tests/army/query/function/cast.py index 2765250d93..977ec82697 100644 --- a/tests/army/query/function/cast.py +++ b/tests/army/query/function/cast.py @@ -265,8 +265,9 @@ class TDTestCase(TBase): tdSql.checkData(0, 0, 3.141) sql = f"select cast({float_1001} as binary(10)) as re;" + tdLog.debug(sql) tdSql.query(sql) - tdSql.checkData(0, 0, 3.141593) + tdSql.checkData(0, 0, 3.14159265) tdSql.query(f"select cast({float_1001} as nchar(5));") tdSql.checkData(0, 0, 3.141) diff --git a/tests/army/query/test_case_when.py b/tests/army/query/test_case_when.py index e772914183..101311d6c0 100644 --- a/tests/army/query/test_case_when.py +++ b/tests/army/query/test_case_when.py @@ -142,13 +142,14 @@ class TDTestCase(TBase): assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) tdSql.query("select case when c_float is not null then c_float else c_null end from st1;") - assert(tdSql.checkRows(10) and tdSql.res == [('2.200000',), ('3.300000',), ('4.400000',), ('5.500000',), ('6.600000',), ('7.700000',), ('8.800000',), ('9.900000',), ('10.100000',), (None,)]) + assert(tdSql.checkRows(10) and tdSql.res == [('2.2',), ('3.3',), ('4.4',), ('5.5',), ('6.6',), ('7.7',), ('8.8',), ('9.9',), ('10.1',), (None,)]) tdSql.query("select case when c_double is null then c_double else c_null end from st1;") assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) - + tdSql.query("select case when c_double is not null then c_double else c_null end from st1;") - assert(tdSql.checkRows(10) and tdSql.res == [('2.220000',), ('3.330000',), ('4.440000',), ('5.550000',), ('6.660000',), ('7.770000',), ('8.880000',), ('9.990000',), ('10.101000',), (None,)]) + + assert(tdSql.checkRows(10) and tdSql.res == [('2.22',), ('3.33',), ('4.44',), ('5.55',), ('6.66',), ('7.77',), ('8.88',), ('9.99',), ('10.101',), (None,)]) tdSql.query("select case when c_varchar is null then c_varchar else c_null end from st1;") assert(tdSql.checkRows(10) and all([item[0] is None for item in tdSql.res])) @@ -344,7 +345,8 @@ class TDTestCase(TBase): assert(tdSql.checkRows(10) and tdSql.res == [('-2147483648',), ('three',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',), ('4294967295',)]) tdSql.query("select case c_float when 2.2 then 9.2233720e+18 when 3.3 then -9.2233720e+18 else 'aa' end from st1;") - assert(tdSql.checkRows(10) and tdSql.res == [('9223372000000000000.000000',), ('-9223372000000000000.000000',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',)]) + print(tdSql.res) + assert(tdSql.checkRows(10) and tdSql.res == [('9.223372e+18',), ('-9.223372e+18',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',), ('aa',)]) tdSql.query("select case t1.c_int when 2 then 'run' when t1.c_int is null then 'other' else t2.c_varchar end from st1 t1, st2 t2 where t1.ts=t2.ts;") print(tdSql.res) diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index cdfe3ce8a0..8d247a690a 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -414,6 +414,29 @@ class TDSql: self.checkRowCol(row, col) return self.cursor.istype(col, dataType) + def checkFloatString(self, row, col, data, show = False): + if row >= self.queryRows: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row+1, self.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col >= self.queryCols: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, col+1, self.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + self.checkRowCol(row, col) + + val = float(self.queryResult[row][col]) + if abs(data) >= 1 and abs((val - data) / data) <= 0.000001: + if(show): + tdLog.info("check successfully") + elif abs(data) < 1 and abs(val - data) <= 0.000001: + if(show): + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) def checkData(self, row, col, data, show = False): if row >= self.queryRows: diff --git a/tests/script/tsim/scalar/caseWhen.sim b/tests/script/tsim/scalar/caseWhen.sim index 4753e24513..0fbec52572 100644 --- a/tests/script/tsim/scalar/caseWhen.sim +++ b/tests/script/tsim/scalar/caseWhen.sim @@ -397,7 +397,7 @@ sql select case when f1 then f1 when f1 + 1 then f1 + 1 else f1 is null end from if $rows != 4 then return -1 endi -if $data00 != 1.000000 then +if $data00 != 1 then return -1 endi if $data10 != 1 then @@ -659,10 +659,10 @@ endi if $data00 != 0 then return -1 endi -if $data10 != 10.000000 then +if $data10 != 10 then return -1 endi -if $data20 != 50.000000 then +if $data20 != 50 then return -1 endi if $data30 != -1 then @@ -889,19 +889,19 @@ endi if $data10 != 0 then return -1 endi -if $data11 != -99.000000 then +if $data11 != -99 then return -1 endi if $data20 != 1 then return -1 endi -if $data21 != 100.000000 then +if $data21 != 100 then return -1 endi if $data30 != 5 then return -1 endi -if $data31 != -94.000000 then +if $data31 != -94 then return -1 endi @@ -1028,7 +1028,7 @@ endi if $data00 != NULL then return -1 endi -if $data10 != -99.000000 then +if $data10 != -99 then return -1 endi if $data20 != 1 then @@ -1051,10 +1051,10 @@ endi if $data21 != NULL then return -1 endi -if $data31 != 101.000000 then +if $data31 != 101 then return -1 endi -if $data41 != 103.000000 then +if $data41 != 103 then return -1 endi @@ -1071,7 +1071,7 @@ sql select case when c_int > 100 then c_float else c_int end as result from t_te if $rows != 1 then return -1 endi -if $data00 != 123.449997 then +if $data00 != 123.45 then return -1 endi @@ -1079,7 +1079,7 @@ sql select case when c_bigint > 100000 then c_double else c_bigint end as result if $rows != 1 then return -1 endi -if $data00 != 678.900000 then +if $data00 != 678.9 then return -1 endi diff --git a/tests/script/tsim/stream/streamTwaInterpFwc.sim b/tests/script/tsim/stream/streamTwaInterpFwc.sim index 050e0282e2..34e6ed8cb7 100644 --- a/tests/script/tsim/stream/streamTwaInterpFwc.sim +++ b/tests/script/tsim/stream/streamTwaInterpFwc.sim @@ -435,7 +435,7 @@ if $data01 != @t12@ then return -1 endi -if $data03 != @100000.000@ then +if $data03 != @100000@ then return -1 endi diff --git a/tests/system-test/2-query/cast.py b/tests/system-test/2-query/cast.py index 11013e09a8..298039f7cc 100644 --- a/tests/system-test/2-query/cast.py +++ b/tests/system-test/2-query/cast.py @@ -305,30 +305,30 @@ class TDTestCase: tdLog.printNoPrefix("==========step21: cast float to binary, expect changes to str(int) ") tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.ct4") for i in range(len(data_ct4_c5)): - tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' ) + tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkFloatString( i, 0, data_ct4_c5[i]) tdSql.query(f"select cast(c5 as binary(32)) as b from {self.dbname}.t1") for i in range(len(data_t1_c5)): - tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' ) + tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkFloatString( i, 0, data_t1_c5[i]) tdSql.query(f"select cast(c5 as binary) as b from {self.dbname}.ct4") for i in range(len(data_ct4_c5)): - tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' ) + tdSql.checkData( i, 0, str(data_ct4_c5[i]) ) if data_ct4_c5[i] is None else tdSql.checkFloatString( i, 0, data_ct4_c5[i]) tdSql.query(f"select cast(c5 as binary) as b from {self.dbname}.t1") for i in range(len(data_t1_c5)): - tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' ) + tdSql.checkData( i, 0, str(data_t1_c5[i]) ) if data_t1_c5[i] is None else tdSql.checkFloatString( i, 0, data_t1_c5[i]) tdLog.printNoPrefix("==========step22: cast float to nchar, expect changes to str(int) ") tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.ct4") for i in range(len(data_ct4_c5)): - tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c5[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_ct4_c5[i] is None else tdSql.checkFloatString( i, 0, data_ct4_c5[i]) tdSql.query(f"select cast(c5 as nchar(32)) as b from {self.dbname}.t1") for i in range(len(data_t1_c5)): - tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkFloatString( i, 0, data_t1_c5[i]) tdSql.query(f"select cast(c5 as nchar) as b from {self.dbname}.t1") for i in range(len(data_t1_c5)): - tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkFloatString( i, 0, data_t1_c5[i]) tdSql.query(f"select cast(c5 as varchar) as b from {self.dbname}.t1") for i in range(len(data_t1_c5)): - tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkData( i, 0, f'{data_t1_c5[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_t1_c5[i] is None else tdSql.checkFloatString( i, 0, data_t1_c5[i]) tdLog.printNoPrefix("==========step23: cast float to timestamp, expect changes to timestamp ") tdSql.query(f"select cast(c5 as timestamp) as b from {self.dbname}.ct4") @@ -367,18 +367,18 @@ class TDTestCase: tdLog.printNoPrefix("==========step25: cast double to binary, expect changes to str(int) ") tdSql.query(f"select cast(c6 as binary(32)) as b from {self.dbname}.ct4") for i in range(len(data_ct4_c6)): - tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c6[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkFloatString( i, 0, data_ct4_c6[i]) tdSql.query(f"select cast(c6 as binary(32)) as b from {self.dbname}.t1") for i in range(len(data_t1_c6)): - tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkData( i, 0, f'{data_t1_c6[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkFloatString( i, 0, data_t1_c6[i]) tdLog.printNoPrefix("==========step26: cast double to nchar, expect changes to str(int) ") tdSql.query(f"select cast(c6 as nchar(32)) as b from {self.dbname}.ct4") for i in range(len(data_ct4_c6)): - tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkData( i, 0, f'{data_ct4_c6[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_ct4_c6[i] is None else tdSql.checkFloatString( i, 0, data_ct4_c6[i]) tdSql.query(f"select cast(c6 as nchar(32)) as b from {self.dbname}.t1") for i in range(len(data_t1_c6)): - tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkData( i, 0, f'{data_t1_c6[i]:.6f}' ) + tdSql.checkData( i, 0, None ) if data_t1_c6[i] is None else tdSql.checkFloatString( i, 0, data_t1_c6[i]) tdLog.printNoPrefix("==========step27: cast double to timestamp, expect changes to timestamp ") tdSql.query(f"select cast(c6 as timestamp) as b from {self.dbname}.ct4") From 54b1f37b1dcb31ca7f6da15371d4458702838b88 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Mon, 10 Feb 2025 18:02:48 +0800 Subject: [PATCH 3/4] fix: shell print float --- source/client/src/clientMain.c | 4 ++-- tools/shell/src/shellEngine.c | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 190a724151..27e21d9a58 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -699,13 +699,13 @@ int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD case TSDB_DATA_TYPE_FLOAT: { float fv = 0; fv = GET_FLOAT_VAL(row[i]); - len += tsnprintf(str + len, size - len, "%f", fv); + len += snprintf(str + len, size - len, "%.*g", FLT_DIG, fv); } break; case TSDB_DATA_TYPE_DOUBLE: { double dv = 0; dv = GET_DOUBLE_VAL(row[i]); - len += tsnprintf(str + len, size - len, "%lf", dv); + len += snprintf(str + len, size - len, "%.*g", DBL_DIG, dv); } break; case TSDB_DATA_TYPE_VARBINARY: { diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index f56a9797f3..5caf13e42e 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -672,12 +672,8 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t if (tsEnableScience) { printf("%*.7e", width, GET_FLOAT_VAL(val)); } else { - n = tsnprintf(buf, LENGTH, "%*.7f", width, GET_FLOAT_VAL(val)); - if (n > SHELL_FLOAT_WIDTH) { - printf("%*.7e", width, GET_FLOAT_VAL(val)); - } else { - printf("%s", buf); - } + n = snprintf(buf, LENGTH, "%.*g", FLT_DIG, GET_FLOAT_VAL(val)); + printf("%s", buf); } break; case TSDB_DATA_TYPE_DOUBLE: @@ -685,12 +681,8 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t snprintf(buf, LENGTH, "%*.15e", width, GET_DOUBLE_VAL(val)); printf("%s", buf); } else { - n = tsnprintf(buf, LENGTH, "%*.15f", width, GET_DOUBLE_VAL(val)); - if (n > SHELL_DOUBLE_WIDTH) { - printf("%*.15e", width, GET_DOUBLE_VAL(val)); - } else { - printf("%*s", width, buf); - } + n = snprintf(buf, LENGTH, "%.*g", DBL_DIG, GET_DOUBLE_VAL(val)); + printf("%s", buf); } break; case TSDB_DATA_TYPE_VARBINARY: { From dfc953074e145137f2b4b7b078049d356eaf0fc7 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Mon, 10 Feb 2025 20:24:21 +0800 Subject: [PATCH 4/4] fix: format case --- tests/army/query/function/ans/ascii.csv | 26 +-- tests/army/query/function/ans/char_length.csv | 28 +-- tests/army/query/function/ans/degrees.csv | 158 +++++++-------- tests/army/query/function/ans/exp.csv | 150 +++++++-------- tests/army/query/function/ans/ln.csv | 134 ++++++------- tests/army/query/function/ans/max.csv | 130 ++++++------- tests/army/query/function/ans/min.csv | 130 ++++++------- tests/army/query/function/ans/mod.csv | 82 ++++---- tests/army/query/function/ans/pi.csv | 80 ++++---- tests/army/query/function/ans/radians.csv | 102 +++++----- tests/army/query/function/ans/rand.csv | 54 +++--- tests/army/query/function/ans/round.csv | 182 +++++++++--------- tests/army/query/function/ans/sign.csv | 118 ++++++------ tests/army/query/function/ans/stddev.csv | 66 +++---- tests/army/query/function/ans/sum.csv | 4 +- tests/army/query/function/ans/trunc.csv | 162 ++++++++-------- tests/army/query/function/ans/varpop.csv | 72 +++---- tools/shell/src/shellEngine.c | 16 +- 18 files changed, 851 insertions(+), 843 deletions(-) diff --git a/tests/army/query/function/ans/ascii.csv b/tests/army/query/function/ans/ascii.csv index 3f1e6b8c5b..8d186f63e3 100644 --- a/tests/army/query/function/ans/ascii.csv +++ b/tests/army/query/function/ans/ascii.csv @@ -27,12 +27,12 @@ taos> select ASCII('北京涛思数据科技有限公司') taos> select ASCII('hello') + 1 ascii('hello') + 1 | ============================ - 105.000000000000000 | + 105 | taos> select ASCII('hello') - 1 ascii('hello') - 1 | ============================ - 103.000000000000000 | + 103 | taos> select ASCII('hello') from ts_4893.meters limit 5 ascii('hello') | @@ -46,7 +46,7 @@ taos> select ASCII('hello') from ts_4893.meters limit 5 taos> select ASCII('hello') + 1 from ts_4893.meters limit 1 ascii('hello') + 1 | ============================ - 105.000000000000000 | + 105 | taos> select ASCII('hello') + ASCII('hello') from ts_4893.meters limit 1 ascii('hello') + ascii('hello') | @@ -92,20 +92,20 @@ taos> select ASCII(cast(nch1 as varchar)) from ts_4893.meters order by ts limit taos> select pow(ASCII(nch1), 2) from ts_4893.meters order by ts limit 5 pow(ascii(nch1), 2) | ============================ - 12100.000000000000000 | - 51984.000000000000000 | - 13689.000000000000000 | - 12544.000000000000000 | - 12100.000000000000000 | + 12100 | + 51984 | + 13689 | + 12544 | + 12100 | taos> select sqrt(ASCII(nch1)) from ts_4893.meters order by ts limit 5 sqrt(ascii(nch1)) | ============================ - 10.488088481701515 | - 15.099668870541500 | - 10.816653826391969 | - 10.583005244258363 | - 10.488088481701515 | + 10.4880884817015 | + 15.0996688705415 | + 10.816653826392 | + 10.5830052442584 | + 10.4880884817015 | taos> select cast(ASCII(nch1) as int) from ts_4893.meters order by ts limit 5 cast(ascii(nch1) as int) | diff --git a/tests/army/query/function/ans/char_length.csv b/tests/army/query/function/ans/char_length.csv index a872e8cd88..4b79a42bfa 100644 --- a/tests/army/query/function/ans/char_length.csv +++ b/tests/army/query/function/ans/char_length.csv @@ -27,12 +27,12 @@ taos> select CHAR_LENGTH('北京涛思数据科技有限公司') taos> select CHAR_LENGTH('hello') + 1 char_length('hello') + 1 | ============================ - 6.000000000000000 | + 6 | taos> select CHAR_LENGTH('hello') - 1 char_length('hello') - 1 | ============================ - 4.000000000000000 | + 4 | taos> select CHAR_LENGTH('hello') from ts_4893.meters limit 5 char_length('hello') | @@ -46,7 +46,7 @@ taos> select CHAR_LENGTH('hello') from ts_4893.meters limit 5 taos> select CHAR_LENGTH('hello') + 1 from ts_4893.meters limit 1 char_length('hello') + 1 | ============================ - 6.000000000000000 | + 6 | taos> select CHAR_LENGTH('hello') + CHAR_LENGTH('hello') from ts_4893.meters limit 1 char_length('hello') + char_length('hello') | @@ -92,20 +92,20 @@ taos> select CHAR_LENGTH(cast(nch1 as varchar)) from ts_4893.meters order by ts taos> select pow(CHAR_LENGTH(nch1), 2) from ts_4893.meters order by ts limit 5 pow(char_length(nch1), 2) | ============================ - 25.000000000000000 | - 100.000000000000000 | - 36.000000000000000 | - 49.000000000000000 | - 25.000000000000000 | + 25 | + 100 | + 36 | + 49 | + 25 | taos> select sqrt(CHAR_LENGTH(nch1)) from ts_4893.meters order by ts limit 5 sqrt(char_length(nch1)) | ============================ - 2.236067977499790 | - 3.162277660168380 | - 2.449489742783178 | - 2.645751311064591 | - 2.236067977499790 | + 2.23606797749979 | + 3.16227766016838 | + 2.44948974278318 | + 2.64575131106459 | + 2.23606797749979 | taos> select cast(CHAR_LENGTH(nch1) as int) from ts_4893.meters order by ts limit 5 cast(char_length(nch1) as int) | @@ -255,5 +255,5 @@ taos> select groupid, max(char_length(name)) from ts_4893.meters group by groupi taos> select location, avg(char_length(name)) from ts_4893.meters group by location order by location location | avg(char_length(name)) | ================================================= - beijing | 3.244600000000000 | + beijing | 3.2446 | diff --git a/tests/army/query/function/ans/degrees.csv b/tests/army/query/function/ans/degrees.csv index 9c68c92a9c..692f6c6c9b 100644 --- a/tests/army/query/function/ans/degrees.csv +++ b/tests/army/query/function/ans/degrees.csv @@ -2,149 +2,149 @@ taos> select DEGREES(0) degrees(0) | ============================ - 0.000000000000000 | + 0 | taos> select DEGREES(1) degrees(1) | ============================ - 57.295779513082323 | + 57.2957795130823 | taos> select DEGREES(1.5) degrees(1.5) | ============================ - 85.943669269623484 | + 85.9436692696235 | taos> select DEGREES(100) degrees(100) | ============================ - 5729.577951308232514 | + 5729.57795130823 | taos> select DEGREES(-1) degrees(-1) | ============================ - -57.295779513082323 | + -57.2957795130823 | taos> select DEGREES(-1.5) degrees(-1.5) | ============================ - -85.943669269623484 | + -85.9436692696235 | taos> select DEGREES(-100) degrees(-100) | ============================ - -5729.577951308232514 | + -5729.57795130823 | taos> select DEGREES(1) + 1 degrees(1) + 1 | ============================ - 58.295779513082323 | + 58.2957795130823 | taos> select DEGREES(1) - 1 degrees(1) - 1 | ============================ - 56.295779513082323 | + 56.2957795130823 | taos> select DEGREES(1) * 1 degrees(1) * 1 | ============================ - 57.295779513082323 | + 57.2957795130823 | taos> select DEGREES(1) / 1 degrees(1) / 1 | ============================ - 57.295779513082323 | + 57.2957795130823 | taos> select DEGREES(1) from ts_4893.meters limit 5 degrees(1) | ============================ - 57.295779513082323 | - 57.295779513082323 | - 57.295779513082323 | - 57.295779513082323 | - 57.295779513082323 | + 57.2957795130823 | + 57.2957795130823 | + 57.2957795130823 | + 57.2957795130823 | + 57.2957795130823 | taos> select DEGREES(1) + 1 from ts_4893.meters limit 1 degrees(1) + 1 | ============================ - 58.295779513082323 | + 58.2957795130823 | taos> select DEGREES(1) - 1 from ts_4893.meters limit 1 degrees(1) - 1 | ============================ - 56.295779513082323 | + 56.2957795130823 | taos> select DEGREES(1) * 2 from ts_4893.meters limit 1 degrees(1) * 2 | ============================ - 114.591559026164646 | + 114.591559026165 | taos> select DEGREES(1) / 2 from ts_4893.meters limit 1 degrees(1) / 2 | ============================ - 28.647889756541161 | + 28.6478897565412 | taos> select DEGREES(2) + DEGREES(1) from ts_4893.meters limit 1 degrees(2) + degrees(1) | ============================ - 171.887338539246969 | + 171.887338539247 | taos> select DEGREES(2) - DEGREES(1) from ts_4893.meters limit 1 degrees(2) - degrees(1) | ============================ - 57.295779513082323 | + 57.2957795130823 | taos> select DEGREES(2) * DEGREES(1) from ts_4893.meters limit 1 degrees(2) * degrees(1) | ============================ - 6565.612700023488287 | + 6565.61270002349 | taos> select DEGREES(2) / DEGREES(1) from ts_4893.meters limit 1 degrees(2) / degrees(1) | ============================ - 2.000000000000000 | + 2 | taos> select DEGREES(1) + id from ts_4893.meters order by ts limit 5 degrees(1) + id | ============================ - 57.295779513082323 | - 58.295779513082323 | - 59.295779513082323 | - 60.295779513082323 | - 61.295779513082323 | + 57.2957795130823 | + 58.2957795130823 | + 59.2957795130823 | + 60.2957795130823 | + 61.2957795130823 | taos> select DEGREES(id) + id from ts_4893.meters order by ts limit 5 degrees(id) + id | ============================ - 0.000000000000000 | - 58.295779513082323 | - 116.591559026164646 | - 174.887338539246969 | - 233.183118052329291 | + 0 | + 58.2957795130823 | + 116.591559026165 | + 174.887338539247 | + 233.183118052329 | taos> select DEGREES(abs(10)) degrees(abs(10)) | ============================ - 572.957795130823229 | + 572.957795130823 | taos> select DEGREES(PI()) degrees(pi()) | ============================ - 180.000000000000000 | + 180 | taos> select abs(DEGREES(10)) abs(degrees(10)) | ============================ - 572.957795130823229 | + 572.957795130823 | taos> select pow(DEGREES(10), 2) pow(degrees(10), 2) | ============================ - 328280.635001174407080 | + 328280.635001174 | taos> select sqrt(DEGREES(10)) sqrt(degrees(10)) | ============================ - 23.936536824085962 | + 23.936536824086 | taos> select cast(DEGREES(10) as int) cast(degrees(10) as int) | @@ -154,44 +154,44 @@ taos> select cast(DEGREES(10) as int) taos> select DEGREES(sqrt(id)) from ts_4893.meters order by ts limit 5 degrees(sqrt(id)) | ============================ - 0.000000000000000 | - 57.295779513082323 | - 81.028468454139556 | - 99.239201175922574 | - 114.591559026164646 | + 0 | + 57.2957795130823 | + 81.0284684541396 | + 99.2392011759226 | + 114.591559026165 | taos> select degrees(pi()) degrees(pi()) | ============================ - 180.000000000000000 | + 180 | taos> select degrees(current) from ts_4893.d0 order by ts limit 10 degrees(current) | ============================ - 610.200029957721426 | - 491.254034090376820 | - 561.212164701962479 | - 643.603479905018958 | - 613.408634263739941 | - 487.472513516777667 | - 549.810284033650078 | - 628.076328902558998 | - 643.202411196955836 | - 592.266466706882511 | + 610.200029957721 | + 491.254034090377 | + 561.212164701962 | + 643.603479905019 | + 613.40863426374 | + 487.472513516778 | + 549.81028403365 | + 628.076328902559 | + 643.202411196956 | + 592.266466706883 | taos> select degrees(current) from ts_4893.meters order by ts limit 10 degrees(current) | ============================ - 610.200029957721426 | - 491.254034090376820 | - 561.212164701962479 | - 643.603479905018958 | - 613.408634263739941 | - 487.472513516777667 | - 549.810284033650078 | - 628.076328902558998 | - 643.202411196955836 | - 592.266466706882511 | + 610.200029957721 | + 491.254034090377 | + 561.212164701962 | + 643.603479905019 | + 613.40863426374 | + 487.472513516778 | + 549.81028403365 | + 628.076328902559 | + 643.202411196956 | + 592.266466706883 | taos> select degrees(null) degrees(null) | @@ -201,70 +201,70 @@ taos> select degrees(null) taos> select degrees(-5) degrees(-5) | ============================ - -286.478897565411614 | + -286.478897565412 | taos> select degrees(3.14) degrees(3.14) | ============================ - 179.908747671078515 | + 179.908747671079 | taos> select degrees(2*pi()) degrees(2*pi()) | ============================ - 360.000000000000000 | + 360 | taos> select degrees(pi()/2) degrees(pi()/2) | ============================ - 90.000000000000000 | + 90 | taos> select degrees(-pi()/2) degrees(-pi()/2) | ============================ - -90.000000000000000 | + -90 | taos> select degrees(1000000) degrees(1000000) | ============================ - 57295779.513082325458527 | + 57295779.5130823 | taos> select degrees(sin(1)) degrees(sin(1)) | ============================ - 48.212736012209490 | + 48.2127360122095 | taos> select degrees(cos(1)) degrees(cos(1)) | ============================ - 30.957041787430903 | + 30.9570417874309 | taos> select degrees(tan(1)) degrees(tan(1)) | ============================ - 89.232889603798512 | + 89.2328896037985 | taos> select degrees(radians(90)) degrees(radians(90)) | ============================ - 90.000000000000000 | + 90 | taos> select degrees(atan(1)) degrees(atan(1)) | ============================ - 45.000000000000000 | + 45 | taos> select degrees(phase) from ts_4893.meters limit 1 degrees(phase) | ============================ - 29.157708736569255 | + 29.1577087365693 | taos> select degrees(current) from ts_4893.meters limit 1 degrees(current) | ============================ - 610.200029957721426 | + 610.200029957721 | taos> select degrees(voltage) from ts_4893.meters limit 1 degrees(voltage) | ============================ - 12662.367272391193183 | + 12662.3672723912 | diff --git a/tests/army/query/function/ans/exp.csv b/tests/army/query/function/ans/exp.csv index c30efe4f55..7831bd8b06 100644 --- a/tests/army/query/function/ans/exp.csv +++ b/tests/army/query/function/ans/exp.csv @@ -2,22 +2,22 @@ taos> select EXP(0) exp(0) | ============================ - 1.000000000000000 | + 1 | taos> select EXP(1) exp(1) | ============================ - 2.718281828459045 | + 2.71828182845905 | taos> select EXP(1.5) exp(1.5) | ============================ - 4.481689070338065 | + 4.48168907033806 | taos> select EXP(100) exp(100) | ============================ - 2.688117141816136e+43 | + 2.68811714181614e+43 | taos> select EXP(-1) exp(-1) | @@ -27,114 +27,114 @@ taos> select EXP(-1) taos> select EXP(-1.5) exp(-1.5) | ============================ - 0.223130160148430 | + 0.22313016014843 | taos> select EXP(-100) exp(-100) | ============================ - 0.000000000000000 | + 3.72007597602084e-44 | taos> select EXP(1) + 1 exp(1) + 1 | ============================ - 3.718281828459045 | + 3.71828182845905 | taos> select EXP(1) - 1 exp(1) - 1 | ============================ - 1.718281828459045 | + 1.71828182845905 | taos> select EXP(1) * 1 exp(1) * 1 | ============================ - 2.718281828459045 | + 2.71828182845905 | taos> select EXP(1) / 1 exp(1) / 1 | ============================ - 2.718281828459045 | + 2.71828182845905 | taos> select exp(1) from ts_4893.meters limit 5 exp(1) | ============================ - 2.718281828459045 | - 2.718281828459045 | - 2.718281828459045 | - 2.718281828459045 | - 2.718281828459045 | + 2.71828182845905 | + 2.71828182845905 | + 2.71828182845905 | + 2.71828182845905 | + 2.71828182845905 | taos> select exp(1) + 1 from ts_4893.meters limit 1 exp(1) + 1 | ============================ - 3.718281828459045 | + 3.71828182845905 | taos> select exp(1) - 1 from ts_4893.meters limit 1 exp(1) - 1 | ============================ - 1.718281828459045 | + 1.71828182845905 | taos> select exp(1) * 2 from ts_4893.meters limit 1 exp(1) * 2 | ============================ - 5.436563656918090 | + 5.43656365691809 | taos> select exp(1) / 2 from ts_4893.meters limit 1 exp(1) / 2 | ============================ - 1.359140914229523 | + 1.35914091422952 | taos> select exp(2) + exp(1) from ts_4893.meters limit 1 exp(2) + exp(1) | ============================ - 10.107337927389695 | + 10.1073379273897 | taos> select exp(2) - exp(1) from ts_4893.meters limit 1 exp(2) - exp(1) | ============================ - 4.670774270471606 | + 4.67077427047161 | taos> select exp(2) * exp(1) from ts_4893.meters limit 1 exp(2) * exp(1) | ============================ - 20.085536923187668 | + 20.0855369231877 | taos> select exp(2) / exp(1) from ts_4893.meters limit 1 exp(2) / exp(1) | ============================ - 2.718281828459046 | + 2.71828182845905 | taos> select exp(1) + id from ts_4893.meters order by ts limit 5 exp(1) + id | ============================ - 2.718281828459045 | - 3.718281828459045 | - 4.718281828459045 | - 5.718281828459045 | - 6.718281828459045 | + 2.71828182845905 | + 3.71828182845905 | + 4.71828182845904 | + 5.71828182845904 | + 6.71828182845904 | taos> select exp(id) + id from ts_4893.meters order by ts limit 5 exp(id) + id | ============================ - 1.000000000000000 | - 3.718281828459045 | - 9.389056098930650 | - 23.085536923187668 | - 58.598150033144236 | + 1 | + 3.71828182845905 | + 9.38905609893065 | + 23.0855369231877 | + 58.5981500331442 | taos> select abs(EXP(10)) abs(exp(10)) | ============================ - 22026.465794806717895 | + 22026.4657948067 | taos> select pow(EXP(10), 2) pow(exp(10), 2) | ============================ - 485165195.409790337085724 | + 485165195.40979 | taos> select sqrt(EXP(10)) sqrt(exp(10)) | ============================ - 148.413159102576600 | + 148.413159102577 | taos> select cast(EXP(10) as int) cast(exp(10) as int) | @@ -144,54 +144,54 @@ taos> select cast(EXP(10) as int) taos> select EXP(sqrt(id)) from ts_4893.meters order by ts limit 5 exp(sqrt(id)) | ============================ - 1.000000000000000 | - 2.718281828459045 | - 4.113250378782928 | - 5.652233674034091 | - 7.389056098930650 | + 1 | + 2.71828182845905 | + 4.11325037878293 | + 5.65223367403409 | + 7.38905609893065 | taos> select EXP(EXP(EXP(EXP(0)))) exp(exp(exp(exp(0)))) | ============================ - 3814279.104760214220732 | + 3814279.10476021 | taos> select exp(2) exp(2) | ============================ - 7.389056098930650 | + 7.38905609893065 | taos> select exp(0.5) exp(0.5) | ============================ - 1.648721270700128 | + 1.64872127070013 | taos> select exp(current) from ts_4893.d0 order by ts limit 10 exp(current) | ============================ - 42192.578453635847836 | - 5292.258432380726845 | - 17943.802618770550907 | - 75583.992598717435612 | - 44622.804904812772293 | - 4954.246535954979663 | - 14705.836248958077704 | - 57641.604897186582093 | - 75056.754435561466380 | - 30853.327779395312973 | + 42192.5784536358 | + 5292.25843238073 | + 17943.8026187706 | + 75583.9925987174 | + 44622.8049048128 | + 4954.24653595498 | + 14705.8362489581 | + 57641.6048971866 | + 75056.7544355615 | + 30853.3277793953 | taos> select exp(current) from ts_4893.meters order by ts limit 10 exp(current) | ============================ - 42192.578453635847836 | - 5292.258432380726845 | - 17943.802618770550907 | - 75583.992598717435612 | - 44622.804904812772293 | - 4954.246535954979663 | - 14705.836248958077704 | - 57641.604897186582093 | - 75056.754435561466380 | - 30853.327779395312973 | + 42192.5784536358 | + 5292.25843238073 | + 17943.8026187706 | + 75583.9925987174 | + 44622.8049048128 | + 4954.24653595498 | + 14705.8362489581 | + 57641.6048971866 | + 75056.7544355615 | + 30853.3277793953 | taos> select exp(null) exp(null) | @@ -206,55 +206,55 @@ taos> select exp(100000) taos> select exp(-1000) exp(-1000) | ============================ - 0.000000000000000 | + 0 | taos> select exp(-9999999999) exp(-9999999999) | ============================ - 0.000000000000000 | + 0 | taos> select exp(0.0001) exp(0.0001) | ============================ - 1.000100005000167 | + 1.00010000500017 | taos> select exp(pi()) exp(pi()) | ============================ - 23.140692632779267 | + 23.1406926327793 | taos> select exp(voltage) from ts_4893.meters limit 1 exp(voltage) | ============================ - 9.529727902367202e+95 | + 9.5297279023672e+95 | taos> select exp(current) from ts_4893.meters limit 1 exp(current) | ============================ - 42192.578453635847836 | + 42192.5784536358 | taos> select exp(phase) from ts_4893.meters limit 1 exp(phase) | ============================ - 1.663457087766762 | + 1.66345708776676 | taos> select exp(voltage + current) from ts_4893.meters limit 1 exp(voltage + current) | ============================ - 4.020837921624308e+100 | + 4.02083792162431e+100 | taos> select exp(abs(current)) from ts_4893.meters limit 1 exp(abs(current)) | ============================ - 42192.578453635847836 | + 42192.5784536358 | taos> select exp(log(voltage)) from ts_4893.meters limit 1 exp(log(voltage)) | ============================ - 220.999999999999915 | + 221 | taos> select round(exp(voltage), 2) from ts_4893.meters limit 1 round(exp(voltage), 2) | ============================ - 9.529727902367202e+95 | + 9.5297279023672e+95 | diff --git a/tests/army/query/function/ans/ln.csv b/tests/army/query/function/ans/ln.csv index 5d6443ab79..3ffcf05582 100644 --- a/tests/army/query/function/ans/ln.csv +++ b/tests/army/query/function/ans/ln.csv @@ -2,7 +2,7 @@ taos> select LN(100) ln(100) | ============================ - 4.605170185988092 | + 4.60517018598809 | taos> select LN(1.5) ln(1.5) | @@ -12,71 +12,71 @@ taos> select LN(1.5) taos> select LN(100) ln(100) | ============================ - 4.605170185988092 | + 4.60517018598809 | taos> select LN(100) + 1 ln(100) + 1 | ============================ - 5.605170185988092 | + 5.60517018598809 | taos> select LN(100) - 1 ln(100) - 1 | ============================ - 3.605170185988092 | + 3.60517018598809 | taos> select LN(100) * 1 ln(100) * 1 | ============================ - 4.605170185988092 | + 4.60517018598809 | taos> select LN(100) / 1 ln(100) / 1 | ============================ - 4.605170185988092 | + 4.60517018598809 | taos> select LN(100) from ts_4893.meters limit 5 ln(100) | ============================ - 4.605170185988092 | - 4.605170185988092 | - 4.605170185988092 | - 4.605170185988092 | - 4.605170185988092 | + 4.60517018598809 | + 4.60517018598809 | + 4.60517018598809 | + 4.60517018598809 | + 4.60517018598809 | taos> select LN(100) + 1 from ts_4893.meters limit 1 ln(100) + 1 | ============================ - 5.605170185988092 | + 5.60517018598809 | taos> select LN(100) - 1 from ts_4893.meters limit 1 ln(100) - 1 | ============================ - 3.605170185988092 | + 3.60517018598809 | taos> select LN(100) * 2 from ts_4893.meters limit 1 ln(100) * 2 | ============================ - 9.210340371976184 | + 9.21034037197618 | taos> select LN(100) / 2 from ts_4893.meters limit 1 ln(100) / 2 | ============================ - 2.302585092994046 | + 2.30258509299405 | taos> select LN(2) + LN(100) from ts_4893.meters limit 1 ln(2) + ln(100) | ============================ - 5.298317366548037 | + 5.29831736654804 | taos> select LN(2) - LN(100) from ts_4893.meters limit 1 ln(2) - ln(100) | ============================ - -3.912023005428146 | + -3.91202300542815 | taos> select LN(2) * LN(100) from ts_4893.meters limit 1 ln(2) * ln(100) | ============================ - 3.192060730416365 | + 3.19206073041636 | taos> select LN(2) / LN(100) from ts_4893.meters limit 1 ln(2) / ln(100) | @@ -86,20 +86,20 @@ taos> select LN(2) / LN(100) from ts_4893.meters limit 1 taos> select LN(100) + id from ts_4893.meters order by ts limit 5 ln(100) + id | ============================ - 4.605170185988092 | - 5.605170185988092 | - 6.605170185988092 | - 7.605170185988092 | - 8.605170185988092 | + 4.60517018598809 | + 5.60517018598809 | + 6.60517018598809 | + 7.60517018598809 | + 8.60517018598809 | taos> select LN(id + 1) + id from ts_4893.meters order by ts limit 5 ln(id + 1) + id | ============================ - 0.000000000000000 | - 1.693147180559945 | - 3.098612288668110 | - 4.386294361119891 | - 5.609437912434101 | + 0 | + 1.69314718055995 | + 3.09861228866811 | + 4.38629436111989 | + 5.6094379124341 | taos> select ln(null) ln(null) | @@ -119,17 +119,17 @@ taos> select ln(-5) taos> select abs(LN(10)) abs(ln(10)) | ============================ - 2.302585092994046 | + 2.30258509299405 | taos> select pow(LN(10), 2) pow(ln(10), 2) | ============================ - 5.301898110478399 | + 5.3018981104784 | taos> select sqrt(LN(10)) sqrt(ln(10)) | ============================ - 1.517427129385146 | + 1.51742712938515 | taos> select cast(LN(10) as int) cast(ln(10) as int) | @@ -139,11 +139,11 @@ taos> select cast(LN(10) as int) taos> select LN(sqrt(id) + 1) from ts_4893.meters order by ts limit 5 ln(sqrt(id) + 1) | ============================ - 0.000000000000000 | + 0 | 0.693147180559945 | 0.881373587019543 | - 1.005052538742381 | - 1.098612288668110 | + 1.00505253874238 | + 1.09861228866811 | taos> select LN(LN(LN(LN(10000)))) ln(ln(ln(ln(10000)))) | @@ -153,70 +153,70 @@ taos> select LN(LN(LN(LN(10000)))) taos> select LN(EXP(2)) ln(exp(2)) | ============================ - 2.000000000000000 | + 2 | taos> select ln(10) ln(10) | ============================ - 2.302585092994046 | + 2.30258509299405 | taos> select ln(pi()) ln(pi()) | ============================ - 1.144729885849400 | + 1.1447298858494 | taos> select ln(current) from ts_4893.d0 order by ts limit 10 ln(current) | ============================ - 2.365559856336680 | - 2.148734409997751 | - 2.281872059185575 | - 2.418855857000369 | - 2.370804362614190 | - 2.141006941277850 | - 2.261346315560232 | - 2.394434736880126 | - 2.418232501568406 | - 2.335729681253415 | + 2.36555985633668 | + 2.14873440999775 | + 2.28187205918557 | + 2.41885585700037 | + 2.37080436261419 | + 2.14100694127785 | + 2.26134631556023 | + 2.39443473688013 | + 2.41823250156841 | + 2.33572968125342 | taos> select ln(current) from ts_4893.meters order by ts limit 10 ln(current) | ============================ - 2.365559856336680 | - 2.148734409997751 | - 2.281872059185575 | - 2.418855857000369 | - 2.370804362614190 | - 2.141006941277850 | - 2.261346315560232 | - 2.394434736880126 | - 2.418232501568406 | - 2.335729681253415 | + 2.36555985633668 | + 2.14873440999775 | + 2.28187205918557 | + 2.41885585700037 | + 2.37080436261419 | + 2.14100694127785 | + 2.26134631556023 | + 2.39443473688013 | + 2.41823250156841 | + 2.33572968125342 | taos> select ln(1) ln(1) | ============================ - 0.000000000000000 | + 0 | taos> select ln(20) ln(20) | ============================ - 2.995732273553991 | + 2.99573227355399 | taos> select ln(100) ln(100) | ============================ - 4.605170185988092 | + 4.60517018598809 | taos> select ln(99999999999999) ln(99999999999999) | ============================ - 32.236191301916627 | + 32.2361913019166 | taos> select ln(0.1) ln(0.1) | ============================ - -2.302585092994045 | + -2.30258509299405 | taos> select ln(2.718) ln(2.718) | @@ -226,17 +226,17 @@ taos> select ln(2.718) taos> select ln(exp(1)) ln(exp(1)) | ============================ - 1.000000000000000 | + 1 | taos> select ln(voltage) from ts_4893.meters where voltage > 0 limit 1 ln(voltage) | ============================ - 5.398162701517752 | + 5.39816270151775 | taos> select ln(current) from ts_4893.meters where current > 0 limit 1 ln(current) | ============================ - 2.365559856336680 | + 2.36555985633668 | taos> select ln(phase) from ts_4893.meters where phase > 0 limit 1 ln(phase) | @@ -246,12 +246,12 @@ taos> select ln(phase) from ts_4893.meters where phase > 0 limit 1 taos> select ln(exp(voltage)) from ts_4893.meters where voltage > 0 limit 1 ln(exp(voltage)) | ============================ - 221.000000000000000 | + 221 | taos> select ln(abs(current)) from ts_4893.meters where current != 0 limit 1 ln(abs(current)) | ============================ - 2.365559856336680 | + 2.36555985633668 | taos> select ln(sqrt(phase)) from ts_4893.meters where phase >= 0 limit 1 ln(sqrt(phase)) | diff --git a/tests/army/query/function/ans/max.csv b/tests/army/query/function/ans/max.csv index 1570e1ebc9..40f8b2ac23 100644 --- a/tests/army/query/function/ans/max.csv +++ b/tests/army/query/function/ans/max.csv @@ -2,7 +2,7 @@ taos> select MAX(current) from ts_4893.meters max(current) | ======================= - 11.9989996 | + 11.999 | taos> select MAX(voltage) from ts_4893.meters max(voltage) | @@ -100,65 +100,65 @@ taos> select MAX(id) from ts_4893.meters interval(60d) taos> select MAX(current) from ts_4893.meters interval(60d) max(current) | ======================= - 11.9989996 | - 11.9969997 | - 11.9969997 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9980001 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9980001 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9980001 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9980001 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9980001 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9980001 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9969997 | - 11.9989996 | - 11.9989996 | - 11.9989996 | - 11.9860001 | + 11.999 | + 11.997 | + 11.997 | + 11.999 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.998 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.998 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.998 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.998 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.998 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.998 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.999 | + 11.999 | + 11.999 | + 11.999 | + 11.997 | + 11.999 | + 11.999 | + 11.999 | + 11.986 | taos> select MAX(voltage) from ts_4893.meters interval(60d) max(voltage) | @@ -561,7 +561,7 @@ taos> select max(id) from ts_4893.meters where id <= 0 taos> select max(phase) from ts_4893.meters where ts between '2023-01-01 00:00:00' and '2023-12-31 23:59:59' max(phase) | ======================= - 0.9999660 | + 0.999966 | taos> select max(voltage) from ts_4893.meters where voltage is not null max(voltage) | @@ -581,12 +581,12 @@ taos> select round(max(current), 2) from ts_4893.meters taos> select pow(max(current), 2) from ts_4893.meters pow(max(current), 2) | ============================ - 143.975991296219036 | + 143.975991296219 | taos> select log(max(voltage) + 1) from ts_4893.meters log(max(voltage) + 1) | ============================ - 5.416100402204420 | + 5.41610040220442 | taos> select groupid, max(voltage) from ts_4893.meters group by groupid order by groupid groupid | max(voltage) | @@ -601,7 +601,7 @@ taos> select location, max(id) from ts_4893.meters group by location order by lo taos> select location, max(current) from ts_4893.meters group by location order by location location | max(current) | ============================================ - beijing | 11.9989996 | + beijing | 11.999 | taos> select max(1) max(1) | @@ -656,5 +656,5 @@ taos> select max(cast(1.1 as float)) taos> select max(cast(1.1 as double)) max(cast(1.1 as double)) | ============================ - 1.100000000000000 | + 1.1 | diff --git a/tests/army/query/function/ans/min.csv b/tests/army/query/function/ans/min.csv index 1ea0c47e81..d77744a4f9 100644 --- a/tests/army/query/function/ans/min.csv +++ b/tests/army/query/function/ans/min.csv @@ -7,7 +7,7 @@ taos> select MIN(id) from ts_4893.meters taos> select MIN(current) from ts_4893.meters min(current) | ======================= - 8.0000000 | + 8 | taos> select MIN(voltage) from ts_4893.meters min(voltage) | @@ -105,65 +105,65 @@ taos> select MIN(id) from ts_4893.meters interval(60d) taos> select MIN(current) from ts_4893.meters interval(60d) min(current) | ======================= - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0010004 | - 8.0010004 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0030003 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0030003 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0010004 | - 8.0089998 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0030003 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0019999 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0000000 | - 8.0019999 | - 8.0010004 | - 8.0000000 | - 8.0050001 | + 8 | + 8 | + 8 | + 8.001 | + 8.001 | + 8 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8.003 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8.003 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8 | + 8 | + 8 | + 8.001 | + 8.009 | + 8 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8.003 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8.002 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8 | + 8 | + 8 | + 8.002 | + 8.001 | + 8 | + 8.005 | taos> select MIN(voltage) from ts_4893.meters interval(60d) min(voltage) | @@ -561,7 +561,7 @@ taos> select min(id) from ts_4893.meters where id <= 0 taos> select min(phase) from ts_4893.meters where ts between '2023-01-01 00:00:00' and '2023-12-31 23:59:59' min(phase) | ======================= - 0.0001700 | + 0.00017 | taos> select min(voltage) from ts_4893.meters where voltage is not null min(voltage) | @@ -581,12 +581,12 @@ taos> select round(min(current), 2) from ts_4893.meters taos> select pow(min(current), 2) from ts_4893.meters pow(min(current), 2) | ============================ - 64.000000000000000 | + 64 | taos> select log(min(voltage) + 1) from ts_4893.meters log(min(voltage) + 1) | ============================ - 5.375278407684165 | + 5.37527840768417 | taos> select groupid, min(voltage) from ts_4893.meters group by groupid order by groupid groupid | min(voltage) | @@ -596,7 +596,7 @@ taos> select groupid, min(voltage) from ts_4893.meters group by groupid order by taos> select location, min(current) from ts_4893.meters group by location order by location location | min(current) | ============================================ - beijing | 8.0000000 | + beijing | 8 | taos> select location, min(id) from ts_4893.meters group by location order by location location | min(id) | @@ -656,5 +656,5 @@ taos> select min(cast(1.1 as float)) taos> select min(cast(1.1 as double)) min(cast(1.1 as double)) | ============================ - 1.100000000000000 | + 1.1 | diff --git a/tests/army/query/function/ans/mod.csv b/tests/army/query/function/ans/mod.csv index fb0a09c14c..9d2232f49d 100644 --- a/tests/army/query/function/ans/mod.csv +++ b/tests/army/query/function/ans/mod.csv @@ -2,7 +2,7 @@ taos> select MOD(10.55, 3) mod(10.55, 3) | ============================ - 1.550000000000001 | + 1.55 | taos> select MOD(10.55, 2) mod(10.55, 2) | @@ -32,12 +32,12 @@ taos> select MOD(-10.55, 1) taos> select MOD(99, 1) mod(99, 1) | ============================ - 0.000000000000000 | + 0 | taos> select MOD(10.55, 1) + 1 mod(10.55, 1) + 1 | ============================ - 1.550000000000001 | + 1.55 | taos> select MOD(MOD(MOD(MOD(MOD(MOD(MOD(123.123456789, 9), 8), 7), 6), 5), 4), 3) mod(mod(mod(mod(mod(mod(mod(123.123456789, 9), 8), 7), 6), 5), 4 | @@ -69,12 +69,12 @@ taos> select MOD(current, id + 1) from ts_4893.meters order by ts limit 10 0.649999618530273 | 0.574000358581543 | 0.795000076293945 | - 3.232999801635742 | + 3.23299980163574 | 0.706000328063965 | - 2.508000373840332 | - 2.595999717712402 | - 2.961999893188477 | - 2.225999832153320 | + 2.50800037384033 | + 2.5959997177124 | + 2.96199989318848 | + 2.22599983215332 | 0.336999893188477 | taos> select MOD(current, 1) from ts_4893.meters order by ts limit 10 @@ -88,7 +88,7 @@ taos> select MOD(current, 1) from ts_4893.meters order by ts limit 10 0.508000373840332 | 0.595999717712402 | 0.961999893188477 | - 0.225999832153320 | + 0.22599983215332 | 0.336999893188477 | taos> select MOD(sqrt(current), abs(id + 1)) from ts_4893.meters order by ts limit 10 @@ -108,40 +108,40 @@ taos> select MOD(sqrt(current), abs(id + 1)) from ts_4893.meters order by ts lim taos> select mod(10, -3) mod(10, -3) | ============================ - 1.000000000000000 | + 1 | taos> select mod(10, 3) mod(10, 3) | ============================ - 1.000000000000000 | + 1 | taos> select mod(id, 3) from ts_4893.d0 order by ts limit 10 mod(id, 3) | ============================ - 0.000000000000000 | - 1.000000000000000 | - 2.000000000000000 | - 0.000000000000000 | - 1.000000000000000 | - 2.000000000000000 | - 0.000000000000000 | - 1.000000000000000 | - 2.000000000000000 | - 0.000000000000000 | + 0 | + 1 | + 2 | + 0 | + 1 | + 2 | + 0 | + 1 | + 2 | + 0 | taos> select mod(id, 3) from ts_4893.meters order by ts limit 10 mod(id, 3) | ============================ - 0.000000000000000 | - 1.000000000000000 | - 2.000000000000000 | - 0.000000000000000 | - 1.000000000000000 | - 2.000000000000000 | - 0.000000000000000 | - 1.000000000000000 | - 2.000000000000000 | - 0.000000000000000 | + 0 | + 1 | + 2 | + 0 | + 1 | + 2 | + 0 | + 1 | + 2 | + 0 | taos> select mod(null, 2) mod(null, 2) | @@ -171,37 +171,37 @@ taos> select mod(5, 0) taos> select mod(0, 1) mod(0, 1) | ============================ - 0.000000000000000 | + 0 | taos> select mod(1, 1) mod(1, 1) | ============================ - 0.000000000000000 | + 0 | taos> select mod(5, 2) mod(5, 2) | ============================ - 1.000000000000000 | + 1 | taos> select mod(5, -3) mod(5, -3) | ============================ - 2.000000000000000 | + 2 | taos> select mod(15, 4) mod(15, 4) | ============================ - 3.000000000000000 | + 3 | taos> select mod(-5, 3) mod(-5, 3) | ============================ - -2.000000000000000 | + -2 | taos> select mod(voltage, 2) from ts_4893.meters limit 1 mod(voltage, 2) | ============================ - 1.000000000000000 | + 1 | taos> select mod(current, 10) from ts_4893.meters limit 1 mod(current, 10) | @@ -211,7 +211,7 @@ taos> select mod(current, 10) from ts_4893.meters limit 1 taos> select mod(current, log(100)) from ts_4893.meters limit 1 mod(current, log(100)) | ============================ - 1.439659246554090 | + 1.43965924655409 | taos> select mod(phase, 4) from ts_4893.meters limit 1 mod(phase, 4) | @@ -221,7 +221,7 @@ taos> select mod(phase, 4) from ts_4893.meters limit 1 taos> select mod(abs(voltage), 3) from ts_4893.meters limit 1 mod(abs(voltage), 3) | ============================ - 2.000000000000000 | + 2 | taos> select mod(phase, sqrt(16)) from ts_4893.meters limit 1 mod(phase, sqrt(16)) | @@ -231,5 +231,5 @@ taos> select mod(phase, sqrt(16)) from ts_4893.meters limit 1 taos> select mod(round(voltage), 5) from ts_4893.meters limit 1 mod(round(voltage), 5) | ============================ - 1.000000000000000 | + 1 | diff --git a/tests/army/query/function/ans/pi.csv b/tests/army/query/function/ans/pi.csv index 1afc45f953..fb7d662ca3 100644 --- a/tests/army/query/function/ans/pi.csv +++ b/tests/army/query/function/ans/pi.csv @@ -2,100 +2,100 @@ taos> select pi() pi() | ============================ - 3.141592653589793 | + 3.14159265358979 | taos> select pi() + 1 pi() + 1 | ============================ - 4.141592653589793 | + 4.14159265358979 | taos> select pi() - 1 pi() - 1 | ============================ - 2.141592653589793 | + 2.14159265358979 | taos> select pi() * 2 pi() * 2 | ============================ - 6.283185307179586 | + 6.28318530717959 | taos> select pi() / 2 pi() / 2 | ============================ - 1.570796326794897 | + 1.5707963267949 | taos> select pi() from ts_4893.meters limit 5 pi() | ============================ - 3.141592653589793 | - 3.141592653589793 | - 3.141592653589793 | - 3.141592653589793 | - 3.141592653589793 | + 3.14159265358979 | + 3.14159265358979 | + 3.14159265358979 | + 3.14159265358979 | + 3.14159265358979 | taos> select pi() + 1 from ts_4893.meters limit 1 pi() + 1 | ============================ - 4.141592653589793 | + 4.14159265358979 | taos> select pi() - 1 from ts_4893.meters limit 1 pi() - 1 | ============================ - 2.141592653589793 | + 2.14159265358979 | taos> select pi() * 2 from ts_4893.meters limit 1 pi() * 2 | ============================ - 6.283185307179586 | + 6.28318530717959 | taos> select pi() / 2 from ts_4893.meters limit 1 pi() / 2 | ============================ - 1.570796326794897 | + 1.5707963267949 | taos> select pi() + pi() from ts_4893.meters limit 1 pi() + pi() | ============================ - 6.283185307179586 | + 6.28318530717959 | taos> select pi() - pi() from ts_4893.meters limit 1 pi() - pi() | ============================ - 0.000000000000000 | + 0 | taos> select pi() * pi() from ts_4893.meters limit 1 pi() * pi() | ============================ - 9.869604401089358 | + 9.86960440108936 | taos> select pi() / pi() from ts_4893.meters limit 1 pi() / pi() | ============================ - 1.000000000000000 | + 1 | taos> select pi() + id from ts_4893.meters order by ts limit 5 pi() + id | ============================ - 3.141592653589793 | - 4.141592653589793 | - 5.141592653589793 | - 6.141592653589793 | - 7.141592653589793 | + 3.14159265358979 | + 4.14159265358979 | + 5.14159265358979 | + 6.14159265358979 | + 7.14159265358979 | taos> select abs(pi()) abs(pi()) | ============================ - 3.141592653589793 | + 3.14159265358979 | taos> select pow(pi(), 2) pow(pi(), 2) | ============================ - 9.869604401089358 | + 9.86960440108936 | taos> select sqrt(pi()) sqrt(pi()) | ============================ - 1.772453850905516 | + 1.77245385090552 | taos> select cast(pi() as int) cast(pi() as int) | @@ -105,7 +105,7 @@ taos> select cast(pi() as int) taos> select pi() pi() | ============================ - 3.141592653589793 | + 3.14159265358979 | taos> select substring_index(null, '.', 2) substring_index(null, '.', 2) | @@ -120,7 +120,7 @@ taos> select pi() + null taos> select pi() * 0 pi() * 0 | ============================ - 0.000000000000000 | + 0 | taos> select pi() / 0 pi() / 0 | @@ -130,62 +130,62 @@ taos> select pi() / 0 taos> select pi() * 0.5 pi() * 0.5 | ============================ - 1.570796326794897 | + 1.5707963267949 | taos> select pi() * -1 pi() * -1 | ============================ - -3.141592653589793 | + -3.14159265358979 | taos> select pi() * name from ts_4893.meters limit 1 pi() * name | ============================ - 0.000000000000000 | + 0 | taos> select pi() * voltage from ts_4893.meters limit 1 pi() * voltage | ============================ - 694.291976443344311 | + 694.291976443344 | taos> select pi() * phase * 2 from ts_4893.meters limit 1 pi() * phase * 2 | ============================ - 3.197500560801395 | + 3.19750056080139 | taos> select round(pi(), 6) round(pi(), 6) | ============================ - 3.141593000000000 | + 3.141593 | taos> select round(pi() * phase, 2) from ts_4893.meters limit 1 round(pi() * phase, 2) | ============================ - 1.600000000000000 | + 1.6 | taos> select sqrt(pi() * voltage) from ts_4893.meters limit 1 sqrt(pi() * voltage) | ============================ - 26.349420799010826 | + 26.3494207990108 | taos> select sqrt(current / pi()) from ts_4893.meters limit 1 sqrt(current / pi()) | ============================ - 1.841195309148865 | + 1.84119530914887 | taos> select abs(pi() * phase) from ts_4893.meters limit 1 abs(pi() * phase) | ============================ - 1.598750280400697 | + 1.5987502804007 | taos> select log(pi() * voltage) from ts_4893.meters limit 1 log(pi() * voltage) | ============================ - 6.542892587367153 | + 6.54289258736715 | taos> select voltage / pi() from ts_4893.meters limit 1 voltage / pi() | ============================ - 70.346484846617741 | + 70.3464848466177 | taos> select id, case when voltage > 100 then pi() else pi() / 2 end from ts_4893.meters limit 1 id | case when voltage > 100 then pi() else pi() / 2 end | diff --git a/tests/army/query/function/ans/radians.csv b/tests/army/query/function/ans/radians.csv index 83814344bc..13042cfc72 100644 --- a/tests/army/query/function/ans/radians.csv +++ b/tests/army/query/function/ans/radians.csv @@ -2,42 +2,42 @@ taos> select RADIANS(0) radians(0) | ============================ - 0.000000000000000 | + 0 | taos> select RADIANS(1) radians(1) | ============================ - 0.017453292519943 | + 0.0174532925199433 | taos> select RADIANS(1.5) radians(1.5) | ============================ - 0.026179938779915 | + 0.0261799387799149 | taos> select RADIANS(100) radians(100) | ============================ - 1.745329251994330 | + 1.74532925199433 | taos> select RADIANS(-1) radians(-1) | ============================ - -0.017453292519943 | + -0.0174532925199433 | taos> select RADIANS(-1.5) radians(-1.5) | ============================ - -0.026179938779915 | + -0.0261799387799149 | taos> select RADIANS(-100) radians(-100) | ============================ - -1.745329251994330 | + -1.74532925199433 | taos> select RADIANS(1) + 1 radians(1) + 1 | ============================ - 1.017453292519943 | + 1.01745329251994 | taos> select RADIANS(1) - 1 radians(1) - 1 | @@ -47,26 +47,26 @@ taos> select RADIANS(1) - 1 taos> select RADIANS(1) * 1 radians(1) * 1 | ============================ - 0.017453292519943 | + 0.0174532925199433 | taos> select RADIANS(1) / 1 radians(1) / 1 | ============================ - 0.017453292519943 | + 0.0174532925199433 | taos> select RADIANS(1) from ts_4893.meters limit 5 radians(1) | ============================ - 0.017453292519943 | - 0.017453292519943 | - 0.017453292519943 | - 0.017453292519943 | - 0.017453292519943 | + 0.0174532925199433 | + 0.0174532925199433 | + 0.0174532925199433 | + 0.0174532925199433 | + 0.0174532925199433 | taos> select RADIANS(1) + 1 from ts_4893.meters limit 1 radians(1) + 1 | ============================ - 1.017453292519943 | + 1.01745329251994 | taos> select RADIANS(1) - 1 from ts_4893.meters limit 1 radians(1) - 1 | @@ -76,50 +76,50 @@ taos> select RADIANS(1) - 1 from ts_4893.meters limit 1 taos> select RADIANS(1) * 2 from ts_4893.meters limit 1 radians(1) * 2 | ============================ - 0.034906585039887 | + 0.0349065850398866 | taos> select RADIANS(1) / 2 from ts_4893.meters limit 1 radians(1) / 2 | ============================ - 0.008726646259972 | + 0.00872664625997165 | taos> select RADIANS(2) + RADIANS(1) from ts_4893.meters limit 1 radians(2) + radians(1) | ============================ - 0.052359877559830 | + 0.0523598775598299 | taos> select RADIANS(2) - RADIANS(1) from ts_4893.meters limit 1 radians(2) - radians(1) | ============================ - 0.017453292519943 | + 0.0174532925199433 | taos> select RADIANS(2) * RADIANS(1) from ts_4893.meters limit 1 radians(2) * radians(1) | ============================ - 0.000609234839573 | + 0.000609234839573417 | taos> select RADIANS(2) / RADIANS(1) from ts_4893.meters limit 1 radians(2) / radians(1) | ============================ - 2.000000000000000 | + 2 | taos> select RADIANS(1) + id from ts_4893.meters order by ts limit 5 radians(1) + id | ============================ - 0.017453292519943 | - 1.017453292519943 | - 2.017453292519943 | - 3.017453292519943 | - 4.017453292519943 | + 0.0174532925199433 | + 1.01745329251994 | + 2.01745329251994 | + 3.01745329251994 | + 4.01745329251994 | taos> select RADIANS(id) + id from ts_4893.meters order by ts limit 5 radians(id) + id | ============================ - 0.000000000000000 | - 1.017453292519943 | - 2.034906585039887 | - 3.052359877559830 | - 4.069813170079773 | + 0 | + 1.01745329251994 | + 2.03490658503989 | + 3.05235987755983 | + 4.06981317007977 | taos> select RADIANS(abs(10)) radians(abs(10)) | @@ -129,7 +129,7 @@ taos> select RADIANS(abs(10)) taos> select RADIANS(DEGREES(PI())) radians(degrees(pi())) | ============================ - 3.141592653589793 | + 3.14159265358979 | taos> select abs(RADIANS(10)) abs(radians(10)) | @@ -139,7 +139,7 @@ taos> select abs(RADIANS(10)) taos> select pow(RADIANS(10), 2) pow(radians(10), 2) | ============================ - 0.030461741978671 | + 0.0304617419786709 | taos> select sqrt(RADIANS(10)) sqrt(radians(10)) | @@ -154,16 +154,16 @@ taos> select cast(RADIANS(10) as int) taos> select RADIANS(sqrt(id)) from ts_4893.meters order by ts limit 5 radians(sqrt(id)) | ============================ - 0.000000000000000 | - 0.017453292519943 | - 0.024682682989769 | - 0.030229989403904 | - 0.034906585039887 | + 0 | + 0.0174532925199433 | + 0.0246826829897687 | + 0.0302299894039036 | + 0.0349065850398866 | taos> select radians(180) radians(180) | ============================ - 3.141592653589793 | + 3.14159265358979 | taos> select radians(current) from ts_4893.d0 order by ts limit 10 radians(current) | @@ -201,7 +201,7 @@ taos> select radians(null) taos> select radians(0) radians(0) | ============================ - 0.000000000000000 | + 0 | taos> select radians(45) radians(45) | @@ -216,22 +216,22 @@ taos> select radians(-45) taos> select radians(90) radians(90) | ============================ - 1.570796326794897 | + 1.5707963267949 | taos> select radians(-90) radians(-90) | ============================ - -1.570796326794897 | + -1.5707963267949 | taos> select radians(360) radians(360) | ============================ - 6.283185307179586 | + 6.28318530717959 | taos> select radians(1000000) radians(1000000) | ============================ - 17453.292519943293883 | + 17453.2925199433 | taos> select radians(sin(1)) radians(sin(1)) | @@ -241,22 +241,22 @@ taos> select radians(sin(1)) taos> select radians(cos(1)) radians(cos(1)) | ============================ - 0.009430054193517 | + 0.00943005419351652 | taos> select radians(tan(1)) radians(tan(1)) | ============================ - 0.027181892591221 | + 0.0271818925912213 | taos> select radians(degrees(90)) radians(degrees(90)) | ============================ - 89.999999999999986 | + 90 | taos> select radians(atan(1)) radians(atan(1)) | ============================ - 0.013707783890402 | + 0.0137077838904019 | taos> select radians(current) from ts_4893.meters limit 1 radians(current) | @@ -266,10 +266,10 @@ taos> select radians(current) from ts_4893.meters limit 1 taos> select radians(voltage) from ts_4893.meters limit 1 radians(voltage) | ============================ - 3.857177646907469 | + 3.85717764690747 | taos> select radians(phase) from ts_4893.meters limit 1 radians(phase) | ============================ - 0.008881946002226 | + 0.0088819460022261 | diff --git a/tests/army/query/function/ans/rand.csv b/tests/army/query/function/ans/rand.csv index 98a096233c..2e87f3404f 100644 --- a/tests/army/query/function/ans/rand.csv +++ b/tests/army/query/function/ans/rand.csv @@ -7,8 +7,8 @@ taos> select RAND(1245) taos> select RAND(id) from ts_4893.d0 limit 10 rand(id) | ============================ - 0.840187717154710 | - 0.840187717154710 | + 0.84018771715471 | + 0.84018771715471 | 0.700976369297587 | 0.561380175203728 | 0.916457875592847 | @@ -35,12 +35,12 @@ taos> select RAND(id) from ts_4893.d0 order by id desc limit 10 taos> select rand(0) rand(0) | ============================ - 0.840187717154710 | + 0.84018771715471 | taos> select rand(1) rand(1) | ============================ - 0.840187717154710 | + 0.84018771715471 | taos> select rand(-1) rand(-1) | @@ -65,13 +65,13 @@ taos> select rand(12345), rand(12345) taos> select rand(9999999999) where rand(9999999999) >= 0 and rand(9999999999) < 1 rand(9999999999) | ============================ - 0.321409397442550 | + 0.32140939744255 | taos> select rand(id) from ts_4893.meters limit 100 rand(id) | ============================ - 0.840187717154710 | - 0.840187717154710 | + 0.84018771715471 | + 0.84018771715471 | 0.700976369297587 | 0.561380175203728 | 0.916457875592847 | @@ -89,22 +89,22 @@ taos> select rand(id) from ts_4893.meters limit 100 0.215437470104283 | 0.571794000254848 | 0.929072778173291 | - 0.290233385418650 | - 0.148812267532950 | + 0.29023338541865 | + 0.14881226753295 | 0.505899571117898 | 0.865026922367991 | 0.727581746283724 | - 0.087714229285584 | + 0.0877142292855839 | 0.939356191986872 | 0.795545781867367 | 0.659832971943465 | 0.517155105023251 | 0.875989373715589 | - 0.229967075041480 | + 0.22996707504148 | 0.592119012303706 | 0.449675684072858 | 0.307948935454688 | - 0.168970021497910 | + 0.16897002149791 | 0.524489704763745 | 0.381259786142623 | 0.239412393066758 | @@ -112,29 +112,29 @@ taos> select rand(id) from ts_4893.meters limit 100 0.957148446215851 | 0.819422913165494 | 0.670246056127477 | - 0.033469948001890 | + 0.0334699480018904 | 0.392149003405193 | 0.749737140606035 | - 0.608923980318440 | + 0.60892398031844 | 0.469695958061933 | 0.825680229266025 | 0.683865774275673 | - 0.041811583583155 | + 0.0418115835831555 | 0.894321223206036 | - 0.760580372885140 | + 0.76058037288514 | 0.615916447069457 | 0.977703406930763 | - 0.329537633959920 | - 0.193522962831670 | - 0.052021294390793 | + 0.32953763395992 | + 0.19352296283167 | + 0.0520212943907926 | 0.911150676622591 | 0.766549994129012 | 0.126697651635249 | - 0.985316422761100 | - 0.843173408342140 | + 0.9853164227611 | + 0.84317340834214 | 0.699550600116863 | 0.557263156192965 | - 0.419794161068180 | + 0.41979416106818 | 0.278590486048996 | 0.133239280028846 | 0.488706417143674 | @@ -147,25 +147,25 @@ taos> select rand(id) from ts_4893.meters limit 100 0.998458440880505 | 0.356983164025928 | 0.218767986269094 | - 0.076468908263589 | + 0.0764689082635888 | 0.431104593179703 | 0.293163777931204 | - 0.650123746902740 | + 0.65012374690274 | 0.510736836358317 | 0.864335399057872 | 0.725284450559544 | - 0.085677149279824 | + 0.0856771492798241 | 0.942077809917777 | 0.798407114482674 | 0.163865051774245 | - 0.017995767769402 | + 0.0179957677694018 | 0.879516513030751 | 0.736922031145972 | 0.589669372695344 | 0.954449085497507 | 0.811225361568493 | 0.172090128609953 | - 0.525153056031630 | + 0.52515305603163 | 0.386470556904781 | 0.744990266275122 | 0.100015020510189 | diff --git a/tests/army/query/function/ans/round.csv b/tests/army/query/function/ans/round.csv index 4f9151c1ad..2c185abd73 100644 --- a/tests/army/query/function/ans/round.csv +++ b/tests/army/query/function/ans/round.csv @@ -2,42 +2,42 @@ taos> select ROUND(10.55, 3) round(10.55, 3) | ============================ - 10.550000000000001 | + 10.55 | taos> select ROUND(10.55, 2) round(10.55, 2) | ============================ - 10.550000000000001 | + 10.55 | taos> select ROUND(10.55, 1) round(10.55, 1) | ============================ - 10.600000000000000 | + 10.6 | taos> select ROUND(10.55, 0) round(10.55, 0) | ============================ - 11.000000000000000 | + 11 | taos> select ROUND(10.55) round(10.55) | ============================ - 11.000000000000000 | + 11 | taos> select ROUND(10.55, -1) round(10.55, -1) | ============================ - 10.000000000000000 | + 10 | taos> select ROUND(10.55, -10) round(10.55, -10) | ============================ - 0.000000000000000 | + 0 | taos> select ROUND(-10.55, 1) round(-10.55, 1) | ============================ - -10.600000000000000 | + -10.6 | taos> select ROUND(99, 1) round(99, 1) | @@ -47,22 +47,22 @@ taos> select ROUND(99, 1) taos> select ROUND(111.1111) round(111.1111) | ============================ - 111.000000000000000 | + 111 | taos> select ROUND(111.5111) round(111.5111) | ============================ - 112.000000000000000 | + 112 | taos> select ROUND(10.55) + 1 round(10.55) + 1 | ============================ - 12.000000000000000 | + 12 | taos> select ROUND(10.55, 1) + 1 round(10.55, 1) + 1 | ============================ - 11.600000000000000 | + 11.6 | taos> select ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(123.123456789, 9), 8), 7), 6), 5), 4)) round(round(round(round(round(round(round(123.123456789, 9), 8), | @@ -77,26 +77,26 @@ taos> select ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(123456789.123456789, -1), taos> select ROUND(current) from ts_4893.meters order by ts limit 20 round(current) | ======================= - 11.0000000 | - 9.0000000 | - 10.0000000 | - 11.0000000 | - 11.0000000 | - 9.0000000 | - 10.0000000 | - 11.0000000 | - 11.0000000 | - 10.0000000 | - 11.0000000 | - 9.0000000 | - 11.0000000 | - 8.0000000 | - 12.0000000 | - 9.0000000 | - 10.0000000 | - 10.0000000 | - 10.0000000 | - 10.0000000 | + 11 | + 9 | + 10 | + 11 | + 11 | + 9 | + 10 | + 11 | + 11 | + 10 | + 11 | + 9 | + 11 | + 8 | + 12 | + 9 | + 10 | + 10 | + 10 | + 10 | taos> select ROUND(87654321.123456789, id) from ts_4893.meters order by ts limit 10 round(87654321.123456789, id) | @@ -115,70 +115,70 @@ taos> select ROUND(87654321.123456789, id) from ts_4893.meters order by ts limit taos> select ROUND(current, id) from ts_4893.meters order by ts limit 10 round(current, id) | ======================= - 11.0000000 | - 8.6000004 | - 9.8000002 | - 11.2329998 | - 10.7060003 | - 8.5080004 | - 9.5959997 | - 10.9619999 | - 11.2259998 | - 10.3369999 | + 11 | + 8.6 | + 9.8 | + 11.233 | + 10.706 | + 8.508 | + 9.596 | + 10.962 | + 11.226 | + 10.337 | taos> select ROUND(current, 1) from ts_4893.meters order by ts limit 10 round(current, 1) | ======================= - 10.6999998 | - 8.6000004 | - 9.8000002 | - 11.1999998 | - 10.6999998 | - 8.5000000 | - 9.6000004 | - 11.0000000 | - 11.1999998 | - 10.3000002 | + 10.7 | + 8.6 | + 9.8 | + 11.2 | + 10.7 | + 8.5 | + 9.6 | + 11 | + 11.2 | + 10.3 | taos> select round(10.55, 3) round(10.55, 3) | ============================ - 10.550000000000001 | + 10.55 | taos> select round(10.55, 2) round(10.55, 2) | ============================ - 10.550000000000001 | + 10.55 | taos> select round(10.55, 1) round(10.55, 1) | ============================ - 10.600000000000000 | + 10.6 | taos> select round(10.55, 0) round(10.55, 0) | ============================ - 11.000000000000000 | + 11 | taos> select round(10.55) round(10.55) | ============================ - 11.000000000000000 | + 11 | taos> select round(10.55, -1) round(10.55, -1) | ============================ - 10.000000000000000 | + 10 | taos> select round(10.55, -10) round(10.55, -10) | ============================ - 0.000000000000000 | + 0 | taos> select round(-10.55, 1) round(-10.55, 1) | ============================ - -10.600000000000000 | + -10.6 | taos> select round(99, 1) round(99, 1) | @@ -188,30 +188,30 @@ taos> select round(99, 1) taos> select round(current) from ts_4893.d0 order by ts limit 10 round(current) | ======================= - 11.0000000 | - 9.0000000 | - 10.0000000 | - 11.0000000 | - 11.0000000 | - 9.0000000 | - 10.0000000 | - 11.0000000 | - 11.0000000 | - 10.0000000 | + 11 | + 9 | + 10 | + 11 | + 11 | + 9 | + 10 | + 11 | + 11 | + 10 | taos> select round(current) from ts_4893.meters order by ts limit 10 round(current) | ======================= - 11.0000000 | - 9.0000000 | - 10.0000000 | - 11.0000000 | - 11.0000000 | - 9.0000000 | - 10.0000000 | - 11.0000000 | - 11.0000000 | - 10.0000000 | + 11 | + 9 | + 10 | + 11 | + 11 | + 9 | + 10 | + 11 | + 11 | + 10 | taos> select round(10, null) round(10, null) | @@ -236,32 +236,32 @@ taos> select round(100) taos> select round(0.00123, -2) round(0.00123, -2) | ============================ - 0.000000000000000 | + 0 | taos> select round(123.456, 0) round(123.456, 0) | ============================ - 123.000000000000000 | + 123 | taos> select round(123.456, -5) round(123.456, -5) | ============================ - 0.000000000000000 | + 0 | taos> select round(12345.6789, -2) round(12345.6789, -2) | ============================ - 12300.000000000000000 | + 12300 | taos> select round(-123.456, 2) round(-123.456, 2) | ============================ - -123.459999999999994 | + -123.46 | taos> select round(-1234.5678, 2) round(-1234.5678, 2) | ============================ - -1234.569999999999936 | + -1234.57 | taos> select round(voltage, 0) from ts_4893.meters limit 1 round(voltage, 0) | @@ -271,12 +271,12 @@ taos> select round(voltage, 0) from ts_4893.meters limit 1 taos> select round(current, 1) from ts_4893.meters limit 1 round(current, 1) | ======================= - 10.6999998 | + 10.7 | taos> select round(phase, 3) from ts_4893.meters limit 1 round(phase, 3) | ======================= - 0.5090000 | + 0.509 | taos> select round(voltage, -1) from ts_4893.meters limit 1 round(voltage, -1) | @@ -296,17 +296,17 @@ taos> select round(abs(voltage), 2) from ts_4893.meters limit 1 taos> select round(pi() * phase, 3) from ts_4893.meters limit 1 round(pi() * phase, 3) | ============================ - 1.599000000000000 | + 1.599 | taos> select round(sqrt(voltage), 2) from ts_4893.meters limit 1 round(sqrt(voltage), 2) | ============================ - 14.869999999999999 | + 14.87 | taos> select round(log(current), 2) from ts_4893.meters limit 1 round(log(current), 2) | ============================ - 2.370000000000000 | + 2.37 | taos> select round(cast(1.0e+400 as float), 0); round(cast(1.0e+400 as float), 0) | diff --git a/tests/army/query/function/ans/sign.csv b/tests/army/query/function/ans/sign.csv index 45679af07f..f8fc961c2b 100644 --- a/tests/army/query/function/ans/sign.csv +++ b/tests/army/query/function/ans/sign.csv @@ -12,7 +12,7 @@ taos> select SIGN(1) taos> select SIGN(1.5) sign(1.5) | ============================ - 1.000000000000000 | + 1 | taos> select SIGN(100) sign(100) | @@ -27,7 +27,7 @@ taos> select SIGN(-1) taos> select SIGN(-1.5) sign(-1.5) | ============================ - -1.000000000000000 | + -1 | taos> select SIGN(-100) sign(-100) | @@ -37,22 +37,22 @@ taos> select SIGN(-100) taos> select SIGN(1) + 1 sign(1) + 1 | ============================ - 2.000000000000000 | + 2 | taos> select SIGN(1) - 1 sign(1) - 1 | ============================ - 0.000000000000000 | + 0 | taos> select SIGN(1) * 1 sign(1) * 1 | ============================ - 1.000000000000000 | + 1 | taos> select SIGN(1) / 1 sign(1) / 1 | ============================ - 1.000000000000000 | + 1 | taos> select SIGN(1) from ts_4893.meters limit 5 sign(1) | @@ -66,60 +66,60 @@ taos> select SIGN(1) from ts_4893.meters limit 5 taos> select SIGN(1) + 1 from ts_4893.meters limit 1 sign(1) + 1 | ============================ - 2.000000000000000 | + 2 | taos> select SIGN(1) - 1 from ts_4893.meters limit 1 sign(1) - 1 | ============================ - 0.000000000000000 | + 0 | taos> select SIGN(1) * 2 from ts_4893.meters limit 1 sign(1) * 2 | ============================ - 2.000000000000000 | + 2 | taos> select SIGN(1) / 2 from ts_4893.meters limit 1 sign(1) / 2 | ============================ - 0.500000000000000 | + 0.5 | taos> select SIGN(2) + SIGN(1) from ts_4893.meters limit 1 sign(2) + sign(1) | ============================ - 2.000000000000000 | + 2 | taos> select SIGN(2) - SIGN(1) from ts_4893.meters limit 1 sign(2) - sign(1) | ============================ - 0.000000000000000 | + 0 | taos> select SIGN(2) * SIGN(1) from ts_4893.meters limit 1 sign(2) * sign(1) | ============================ - 1.000000000000000 | + 1 | taos> select SIGN(2) / SIGN(1) from ts_4893.meters limit 1 sign(2) / sign(1) | ============================ - 1.000000000000000 | + 1 | taos> select SIGN(1) + id from ts_4893.meters order by ts limit 5 sign(1) + id | ============================ - 1.000000000000000 | - 2.000000000000000 | - 3.000000000000000 | - 4.000000000000000 | - 5.000000000000000 | + 1 | + 2 | + 3 | + 4 | + 5 | taos> select SIGN(id) + id from ts_4893.meters order by ts limit 5 sign(id) + id | ============================ - 0.000000000000000 | - 2.000000000000000 | - 3.000000000000000 | - 4.000000000000000 | - 5.000000000000000 | + 0 | + 2 | + 3 | + 4 | + 5 | taos> select sign(cast(1 as tinyint)) sign(cast(1 as tinyint)) | @@ -169,7 +169,7 @@ taos> select sign(cast(1 as float)) taos> select sign(cast(1 as double)) sign(cast(1 as double)) | ============================ - 1.000000000000000 | + 1 | taos> select sign(cast(NULL as tinyint)) sign(cast(null as tinyint)) | @@ -239,12 +239,12 @@ taos> select abs(SIGN(10)) taos> select pow(SIGN(10), 2) pow(sign(10), 2) | ============================ - 1.000000000000000 | + 1 | taos> select sqrt(SIGN(10)) sqrt(sign(10)) | ============================ - 1.000000000000000 | + 1 | taos> select cast(SIGN(10) as int) cast(sign(10) as int) | @@ -254,11 +254,11 @@ taos> select cast(SIGN(10) as int) taos> select SIGN(sqrt(id)) from ts_4893.meters order by ts limit 5 sign(sqrt(id)) | ============================ - 0.000000000000000 | - 1.000000000000000 | - 1.000000000000000 | - 1.000000000000000 | - 1.000000000000000 | + 0 | + 1 | + 1 | + 1 | + 1 | taos> select SIGN(SIGN(SIGN(SIGN(0)))) sign(sign(sign(sign(0)))) | @@ -288,30 +288,30 @@ taos> select sign(-10) taos> select sign(current) from ts_4893.d0 order by ts limit 10 sign(current) | ======================= - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | taos> select sign(current) from ts_4893.meters order by ts limit 10 sign(current) | ======================= - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | - 1.0000000 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | + 1 | taos> select sign(cast(current as float)) from ts_4893.d0 order by ts limit 10 sign(cast(current as float)) | @@ -359,17 +359,17 @@ taos> select sign(-10) taos> select sign(0.1) sign(0.1) | ============================ - 1.000000000000000 | + 1 | taos> select sign(-0.1) sign(-0.1) | ============================ - -1.000000000000000 | + -1 | taos> select sign(current) from ts_4893.meters limit 1 sign(current) | ======================= - 1.0000000 | + 1 | taos> select sign(voltage) from ts_4893.meters limit 1 sign(voltage) | @@ -379,7 +379,7 @@ taos> select sign(voltage) from ts_4893.meters limit 1 taos> select sign(phase) from ts_4893.meters limit 1 sign(phase) | ======================= - 1.0000000 | + 1 | taos> select sign(abs(voltage)) from ts_4893.meters limit 1 sign(abs(voltage)) | @@ -389,15 +389,15 @@ taos> select sign(abs(voltage)) from ts_4893.meters limit 1 taos> select sign(round(current)) from ts_4893.meters limit 1 sign(round(current)) | ======================= - 1.0000000 | + 1 | taos> select sign(sqrt(voltage)) from ts_4893.meters limit 1 sign(sqrt(voltage)) | ============================ - 1.000000000000000 | + 1 | taos> select sign(log(current + 1)) from ts_4893.meters limit 1 sign(log(current + 1)) | ============================ - 1.000000000000000 | + 1 | diff --git a/tests/army/query/function/ans/stddev.csv b/tests/army/query/function/ans/stddev.csv index 95af278013..c0f93a9bcd 100644 --- a/tests/army/query/function/ans/stddev.csv +++ b/tests/army/query/function/ans/stddev.csv @@ -2,7 +2,7 @@ taos> select STDDEV(current) from ts_4893.meters stddev(current) | ============================ - 1.154339668872967 | + 1.15433966887297 | taos> select STDDEV(current) from ts_4893.meters interval(1d) order by 1 limit 10 stddev(current) | @@ -21,40 +21,40 @@ taos> select STDDEV(current) from ts_4893.meters interval(1d) order by 1 limit 1 taos> select STDDEV(id) from ts_4893.meters stddev(id) | ============================ - 2886.751331514371941 | + 2886.75133151437 | taos> select STDDEV(id) from ts_4893.meters interval(1d) limit 10 stddev(id) | ============================ - 4.609772228646444 | - 8.366600265340756 | - 8.366600265340756 | - 8.366600265340756 | - 8.366600265340756 | - 8.077747210701755 | - 8.366600265340756 | - 8.366600265340756 | - 8.366600265340756 | - 8.366600265340756 | + 4.60977222864644 | + 8.36660026534076 | + 8.36660026534076 | + 8.36660026534076 | + 8.36660026534076 | + 8.07774721070176 | + 8.36660026534076 | + 8.36660026534076 | + 8.36660026534076 | + 8.36660026534076 | taos> select STDDEV(id) from ts_4893.meters where id > 100 stddev(id) | ============================ - 2857.595142773027419 | + 2857.59514277303 | taos> select STDDEV(id) from ts_4893.meters interval(1d) order by 1 limit 10 stddev(id) | ============================ - 4.609772228646444 | - 5.477225575051661 | - 8.077747210701755 | - 8.077747210701755 | - 8.077747210701755 | - 8.077747210701755 | - 8.077747210701755 | - 8.077747210701755 | - 8.077747210701755 | - 8.077747210701755 | + 4.60977222864644 | + 5.47722557505166 | + 8.07774721070176 | + 8.07774721070176 | + 8.07774721070176 | + 8.07774721070176 | + 8.07774721070176 | + 8.07774721070176 | + 8.07774721070176 | + 8.07774721070176 | taos> select stddev_pop(null) from ts_4893.meters stddev_pop(null) | @@ -64,32 +64,32 @@ taos> select stddev_pop(null) from ts_4893.meters taos> select stddev_pop(id) from ts_4893.d0 stddev_pop(id) | ============================ - 2886.751331514371941 | + 2886.75133151437 | taos> select stddev_pop(id) from ts_4893.meters stddev_pop(id) | ============================ - 2886.751331514371941 | + 2886.75133151437 | taos> select stddev_pop(current) from ts_4893.d0 stddev_pop(current) | ============================ - 1.154339668872967 | + 1.15433966887297 | taos> select stddev_pop(current) from ts_4893.meters stddev_pop(current) | ============================ - 1.154339668872967 | + 1.15433966887297 | taos> select stddev_pop(voltage) from ts_4893.meters stddev_pop(voltage) | ============================ - 2.876459705957324 | + 2.87645970595732 | taos> select stddev_pop(voltage) from ts_4893.meters where voltage is not null stddev_pop(voltage) | ============================ - 2.876459705957324 | + 2.87645970595732 | taos> select stddev_pop(phase) from ts_4893.meters stddev_pop(phase) | @@ -104,7 +104,7 @@ taos> select stddev_pop(phase) from ts_4893.meters where ts between '2023-01-01 taos> select stddev_pop(total_voltage) from (select sum(voltage) as total_voltage from ts_4893.meters group by location) stddev_pop(total_voltage) | ============================ - 0.000000000000000 | + 0 | taos> select round(stddev_pop(current), 2) from ts_4893.meters round(stddev_pop(current), 2) | @@ -124,15 +124,15 @@ taos> select log(stddev_pop(voltage) + 1) from ts_4893.meters taos> select groupid, stddev_pop(voltage) from ts_4893.meters group by groupid order by groupid groupid | stddev_pop(voltage) | ====================================== - 1 | 2.876459705957324 | + 1 | 2.87645970595732 | taos> select location, stddev_pop(current) from ts_4893.meters group by location order by location location | stddev_pop(current) | ================================================= - beijing | 1.154339668872967 | + beijing | 1.15433966887297 | taos> select location, stddev_pop(voltage) from ts_4893.meters group by location order by location location | stddev_pop(voltage) | ================================================= - beijing | 2.876459705957324 | + beijing | 2.87645970595732 | diff --git a/tests/army/query/function/ans/sum.csv b/tests/army/query/function/ans/sum.csv index 3444b3f710..0074b775b7 100644 --- a/tests/army/query/function/ans/sum.csv +++ b/tests/army/query/function/ans/sum.csv @@ -47,10 +47,10 @@ taos> select sum(cast(10000000000 as bigint unsigned)) taos> select sum(cast(1.1 as float)) sum(cast(1.1 as float)) | ============================ - 1.100000023841858 | + 1.10000002384186 | taos> select sum(cast(1.1 as double)) sum(cast(1.1 as double)) | ============================ - 1.100000000000000 | + 1.1 | diff --git a/tests/army/query/function/ans/trunc.csv b/tests/army/query/function/ans/trunc.csv index e553f3acb5..15411afbf3 100644 --- a/tests/army/query/function/ans/trunc.csv +++ b/tests/army/query/function/ans/trunc.csv @@ -2,37 +2,37 @@ taos> select TRUNCATE(10.55, 3) truncate(10.55, 3) | ============================ - 10.550000000000001 | + 10.55 | taos> select TRUNCATE(10.55, 2) truncate(10.55, 2) | ============================ - 10.550000000000001 | + 10.55 | taos> select TRUNCATE(10.55, 1) truncate(10.55, 1) | ============================ - 10.500000000000000 | + 10.5 | taos> select TRUNCATE(10.55, 0) truncate(10.55, 0) | ============================ - 10.000000000000000 | + 10 | taos> select TRUNCATE(10.55, -1) truncate(10.55, -1) | ============================ - 10.000000000000000 | + 10 | taos> select TRUNCATE(10.55, -10) truncate(10.55, -10) | ============================ - 0.000000000000000 | + 0 | taos> select TRUNCATE(-10.55, 1) truncate(-10.55, 1) | ============================ - -10.500000000000000 | + -10.5 | taos> select TRUNCATE(99, 1) truncate(99, 1) | @@ -42,7 +42,7 @@ taos> select TRUNCATE(99, 1) taos> select TRUNCATE(10.55, 1) + 1 truncate(10.55, 1) + 1 | ============================ - 11.500000000000000 | + 11.5 | taos> select TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(123.123456789, 9), 8), 7), 6), 5), 4), 3) truncate(truncate(truncate(truncate(truncate(truncate(truncate(1 | @@ -85,51 +85,51 @@ taos> select TRUNCATE(current, id) from ts_4893.meters order by ts limit 10 taos> select TRUNCATE(current, 1) from ts_4893.meters order by ts limit 10 truncate(current, 1) | ======================= - 10.6000004 | - 8.5000000 | - 9.6999998 | - 11.1999998 | - 10.6999998 | - 8.5000000 | - 9.5000000 | - 10.8999996 | - 11.1999998 | - 10.3000002 | + 10.6 | + 8.5 | + 9.7 | + 11.2 | + 10.7 | + 8.5 | + 9.5 | + 10.9 | + 11.2 | + 10.3 | taos> select TRUNC(10.55, 3) trunc(10.55, 3) | ============================ - 10.550000000000001 | + 10.55 | taos> select TRUNC(10.55, 2) trunc(10.55, 2) | ============================ - 10.550000000000001 | + 10.55 | taos> select TRUNC(10.55, 1) trunc(10.55, 1) | ============================ - 10.500000000000000 | + 10.5 | taos> select TRUNC(10.55, 0) trunc(10.55, 0) | ============================ - 10.000000000000000 | + 10 | taos> select TRUNC(10.55, -1) trunc(10.55, -1) | ============================ - 10.000000000000000 | + 10 | taos> select TRUNC(10.55, -10) trunc(10.55, -10) | ============================ - 0.000000000000000 | + 0 | taos> select TRUNC(-10.55, 1) trunc(-10.55, 1) | ============================ - -10.500000000000000 | + -10.5 | taos> select TRUNC(99, 1) trunc(99, 1) | @@ -139,7 +139,7 @@ taos> select TRUNC(99, 1) taos> select TRUNC(10.55, 1) + 1 trunc(10.55, 1) + 1 | ============================ - 11.500000000000000 | + 11.5 | taos> select TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(123.123456789, 9), 8), 7), 6), 5), 4), 3) trunc(trunc(trunc(trunc(trunc(trunc(trunc(123.123456789, 9), 8), | @@ -168,60 +168,60 @@ taos> select TRUNC(87654321.123456789, id) from ts_4893.meters order by ts limit taos> select TRUNC(current, id) from ts_4893.meters order by ts limit 10 trunc(current, id) | ======================= - 10.0000000 | - 8.5000000 | - 9.7900000 | - 11.2329998 | - 10.7060003 | - 8.5080004 | - 9.5959997 | - 10.9619999 | - 11.2259998 | - 10.3369999 | + 10 | + 8.5 | + 9.79 | + 11.233 | + 10.706 | + 8.508 | + 9.596 | + 10.962 | + 11.226 | + 10.337 | taos> select TRUNC(current, 1) from ts_4893.meters order by ts limit 10 trunc(current, 1) | ======================= - 10.6000004 | - 8.5000000 | - 9.6999998 | - 11.1999998 | - 10.6999998 | - 8.5000000 | - 9.5000000 | - 10.8999996 | - 11.1999998 | - 10.3000002 | + 10.6 | + 8.5 | + 9.7 | + 11.2 | + 10.7 | + 8.5 | + 9.5 | + 10.9 | + 11.2 | + 10.3 | taos> select truncate(99.99, 3) truncate(99.99, 3) | ============================ - 99.989999999999995 | + 99.99 | taos> select truncate(99.99, 2) truncate(99.99, 2) | ============================ - 99.989999999999995 | + 99.99 | taos> select truncate(99.99, 1) truncate(99.99, 1) | ============================ - 99.900000000000006 | + 99.9 | taos> select truncate(99.99, 0) truncate(99.99, 0) | ============================ - 99.000000000000000 | + 99 | taos> select truncate(99.99, -1) truncate(99.99, -1) | ============================ - 90.000000000000000 | + 90 | taos> select truncate(99.99, -10) truncate(99.99, -10) | ============================ - 0.000000000000000 | + 0 | taos> select truncate(99, 1) truncate(99, 1) | @@ -231,30 +231,30 @@ taos> select truncate(99, 1) taos> select truncate(current, 1) from ts_4893.d0 order by ts limit 10 truncate(current, 1) | ======================= - 10.6000004 | - 8.5000000 | - 9.6999998 | - 11.1999998 | - 10.6999998 | - 8.5000000 | - 9.5000000 | - 10.8999996 | - 11.1999998 | - 10.3000002 | + 10.6 | + 8.5 | + 9.7 | + 11.2 | + 10.7 | + 8.5 | + 9.5 | + 10.9 | + 11.2 | + 10.3 | taos> select truncate(current, 1) from ts_4893.meters order by ts limit 10 truncate(current, 1) | ======================= - 10.6000004 | - 8.5000000 | - 9.6999998 | - 11.1999998 | - 10.6999998 | - 8.5000000 | - 9.5000000 | - 10.8999996 | - 11.1999998 | - 10.3000002 | + 10.6 | + 8.5 | + 9.7 | + 11.2 | + 10.7 | + 8.5 | + 9.5 | + 10.9 | + 11.2 | + 10.3 | taos> select truncate(99.99, null) truncate(99.99, null) | @@ -269,22 +269,22 @@ taos> select truncate(null, 3) taos> select truncate(1.0001, 3) truncate(1.0001, 3) | ============================ - 1.000000000000000 | + 1 | taos> select truncate(2.71828, 4) truncate(2.71828, 4) | ============================ - 2.718200000000000 | + 2.7182 | taos> select truncate(3.14159, 2) truncate(3.14159, 2) | ============================ - 3.140000000000000 | + 3.14 | taos> select truncate(100.9876, 2) truncate(100.9876, 2) | ============================ - 100.980000000000004 | + 100.98 | taos> select truncate(99999999999999.9999, 2) truncate(99999999999999.9999, 2) | @@ -294,7 +294,7 @@ taos> select truncate(99999999999999.9999, 2) taos> select truncate(-5.678, 2) truncate(-5.678, 2) | ============================ - -5.670000000000000 | + -5.67 | taos> select truncate(voltage, 2) from ts_4893.meters limit 1 truncate(voltage, 2) | @@ -304,12 +304,12 @@ taos> select truncate(voltage, 2) from ts_4893.meters limit 1 taos> select truncate(current, 1) from ts_4893.meters limit 1 truncate(current, 1) | ======================= - 10.6000004 | + 10.6 | taos> select truncate(phase, 3) from ts_4893.meters limit 1 truncate(phase, 3) | ======================= - 0.5080000 | + 0.508 | taos> select truncate(voltage + current, 2) from ts_4893.meters limit 1 truncate(voltage + current, 2) | @@ -334,10 +334,10 @@ taos> select truncate(abs(current), 1) from ts_4893.meters limit 1 taos> select truncate(exp(phase), 2) from ts_4893.meters limit 1 truncate(exp(phase), 2) | ============================ - 1.660000000000000 | + 1.66 | taos> select truncate(log(current), 1) from ts_4893.meters limit 1 truncate(log(current), 1) | ============================ - 2.300000000000000 | + 2.3 | diff --git a/tests/army/query/function/ans/varpop.csv b/tests/army/query/function/ans/varpop.csv index 7cfb67dbea..829996d978 100644 --- a/tests/army/query/function/ans/varpop.csv +++ b/tests/army/query/function/ans/varpop.csv @@ -2,7 +2,7 @@ taos> select VAR_POP(current) from ts_4893.meters var_pop(current) | ============================ - 1.332500071133751 | + 1.33250007113375 | taos> select VAR_POP(current) from ts_4893.meters interval(1d) order by 1 limit 10 var_pop(current) | @@ -14,47 +14,47 @@ taos> select VAR_POP(current) from ts_4893.meters interval(1d) order by 1 limit 0.706550935286586 | 0.713306900568867 | 0.716868311383919 | - 0.717430738826280 | + 0.71743073882628 | 0.717718552465783 | 0.719483293517456 | taos> select VAR_POP(id) from ts_4893.meters var_pop(id) | ============================ - 8333333.250000000000000 | + 8333333.25 | taos> select VAR_POP(id) from ts_4893.meters interval(1d) limit 10 var_pop(id) | ============================ - 21.250000000000000 | - 70.000000000000000 | - 70.000000000000000 | - 70.000000000000000 | - 70.000000000000000 | - 65.250000000000000 | - 70.000000000000000 | - 70.000000000000000 | - 70.000000000000000 | - 70.000000000000000 | + 21.25 | + 70 | + 70 | + 70 | + 70 | + 65.25 | + 70 | + 70 | + 70 | + 70 | taos> select VAR_POP(id) from ts_4893.meters where id > 100 var_pop(id) | ============================ - 8165850.000000000000000 | + 8165850 | taos> select VAR_POP(id) from ts_4893.meters interval(1d) order by 1 limit 10 var_pop(id) | ============================ - 21.250000000000000 | - 30.000000000000000 | - 65.250000000000000 | - 65.250000000000000 | - 65.250000000000000 | - 65.250000000000000 | - 65.250000000000000 | - 65.250000000000000 | - 65.250000000000000 | - 65.250000000000000 | + 21.25 | + 30 | + 65.25 | + 65.25 | + 65.25 | + 65.25 | + 65.25 | + 65.25 | + 65.25 | + 65.25 | taos> select var_pop(null) from ts_4893.meters var_pop(null) | @@ -64,37 +64,37 @@ taos> select var_pop(null) from ts_4893.meters taos> select var_pop(id) from ts_4893.d0 var_pop(id) | ============================ - 8333333.250000000000000 | + 8333333.25 | taos> select var_pop(current) from ts_4893.d0 var_pop(current) | ============================ - 1.332500071133751 | + 1.33250007113375 | taos> select var_pop(voltage) from ts_4893.meters var_pop(voltage) | ============================ - 8.274020439996093 | + 8.27402043999609 | taos> select var_pop(voltage) from ts_4893.meters where voltage is not null var_pop(voltage) | ============================ - 8.274020439996093 | + 8.27402043999609 | taos> select var_pop(phase) from ts_4893.meters var_pop(phase) | ============================ - 0.083287338468169 | + 0.0832873384681693 | taos> select var_pop(phase) from ts_4893.meters where ts between '2023-01-01 00:00:00' and '2023-12-31 23:59:59' var_pop(phase) | ============================ - 0.082987411872200 | + 0.0829874118722003 | taos> select var_pop(total_voltage) from (select sum(voltage) as total_voltage from ts_4893.meters group by location) var_pop(total_voltage) | ============================ - 0.000000000000000 | + 0 | taos> select round(var_pop(current), 2) from ts_4893.meters round(var_pop(current), 2) | @@ -104,25 +104,25 @@ taos> select round(var_pop(current), 2) from ts_4893.meters taos> select pow(var_pop(current), 2) from ts_4893.meters pow(var_pop(current), 2) | ============================ - 1.775556439571451 | + 1.77555643957145 | taos> select log(var_pop(voltage) + 1) from ts_4893.meters log(var_pop(voltage) + 1) | ============================ - 2.227216989977633 | + 2.22721698997763 | taos> select groupid, var_pop(voltage) from ts_4893.meters group by groupid order by groupid groupid | var_pop(voltage) | ====================================== - 1 | 8.274020439996093 | + 1 | 8.27402043999609 | taos> select location, var_pop(current) from ts_4893.meters group by location order by location location | var_pop(current) | ================================================= - beijing | 1.332500071133751 | + beijing | 1.33250007113375 | taos> select location, var_pop(voltage) from ts_4893.meters group by location order by location location | var_pop(voltage) | ================================================= - beijing | 8.274020439996093 | + beijing | 8.27402043999609 | diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 5caf13e42e..37da47bae6 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -672,8 +672,12 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t if (tsEnableScience) { printf("%*.7e", width, GET_FLOAT_VAL(val)); } else { - n = snprintf(buf, LENGTH, "%.*g", FLT_DIG, GET_FLOAT_VAL(val)); - printf("%s", buf); + n = snprintf(buf, LENGTH, "%*.*g", width, FLT_DIG, GET_FLOAT_VAL(val)); + if (n > SHELL_FLOAT_WIDTH) { + printf("%*.7e", width, GET_FLOAT_VAL(val)); + } else { + printf("%s", buf); + } } break; case TSDB_DATA_TYPE_DOUBLE: @@ -681,8 +685,12 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t snprintf(buf, LENGTH, "%*.15e", width, GET_DOUBLE_VAL(val)); printf("%s", buf); } else { - n = snprintf(buf, LENGTH, "%.*g", DBL_DIG, GET_DOUBLE_VAL(val)); - printf("%s", buf); + n = snprintf(buf, LENGTH, "%*.*g", width, DBL_DIG, GET_DOUBLE_VAL(val)); + if (n > SHELL_DOUBLE_WIDTH) { + printf("%*.15e", width, GET_DOUBLE_VAL(val)); + } else { + printf("%*s", width, buf); + } } break; case TSDB_DATA_TYPE_VARBINARY: {