fix: print folat when title name is too long

This commit is contained in:
factosea 2025-03-06 10:23:01 +08:00
parent 36183aa36b
commit b3ef8b2f44
14 changed files with 111 additions and 119 deletions

View File

@ -51,7 +51,7 @@ taos> select ASCII('hello') + 1 from ts_4893.meters limit 1
taos> select ASCII('hello') + ASCII('hello') from ts_4893.meters limit 1
ascii('hello') + ascii('hello') |
==================================
2.080000000000000e+02 |
208 |
taos> select ASCII(nch1) from ts_4893.meters order by ts limit 5
ascii(nch1) |

Can't render this file because it has a wrong number of fields in line 17.

View File

@ -51,7 +51,7 @@ taos> select CHAR_LENGTH('hello') + 1 from ts_4893.meters limit 1
taos> select CHAR_LENGTH('hello') + CHAR_LENGTH('hello') from ts_4893.meters limit 1
char_length('hello') + char_length('hello') |
==============================================
1.000000000000000e+01 |
10 |
taos> select CHAR_LENGTH(nch1) from ts_4893.meters order by ts limit 5
char_length(nch1) |

Can't render this file because it has a wrong number of fields in line 17.

View File

@ -576,7 +576,7 @@ taos> select max(total_voltage) from (select sum(voltage) as total_voltage from
taos> select round(max(current), 2) from ts_4893.meters
round(max(current), 2) |
=========================
1.2000000e+01 |
12 |
taos> select pow(max(current), 2) from ts_4893.meters
pow(max(current), 2) |
@ -651,7 +651,7 @@ taos> select max(cast(10000000000 as bigint unsigned))
taos> select max(cast(1.1 as float))
max(cast(1.1 as float)) |
==========================
1.1000000e+00 |
1.1 |
taos> select max(cast(1.1 as double))
max(cast(1.1 as double)) |

Can't render this file because it has a wrong number of fields in line 576.

View File

@ -576,7 +576,7 @@ taos> select min(total_voltage) from (select sum(voltage) as total_voltage from
taos> select round(min(current), 2) from ts_4893.meters
round(min(current), 2) |
=========================
8.0000000e+00 |
8 |
taos> select pow(min(current), 2) from ts_4893.meters
pow(min(current), 2) |
@ -651,7 +651,7 @@ taos> select min(cast(10000000000 as bigint unsigned))
taos> select min(cast(1.1 as float))
min(cast(1.1 as float)) |
==========================
1.1000000e+00 |
1.1 |
taos> select min(cast(1.1 as double))
min(cast(1.1 as double)) |

Can't render this file because it has a wrong number of fields in line 576.

View File

@ -42,26 +42,26 @@ taos> select MOD(10.55, 1) + 1
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 |
===================================================================
1.234567890000022e-01 |
0.12345678900000 |
taos> select MOD(MOD(MOD(MOD(MOD(MOD(MOD(123456789.123456789, -1), -2), -3), -4), -5), -6), -7)
mod(mod(mod(mod(mod(mod(mod(123456789.123456789, -1), -2), -3), |
===================================================================
1.234567910432816e-01 |
0.12345679104328 |
taos> select MOD(87654321.123456789, id + 1) from ts_4893.meters order by ts limit 10
mod(87654321.123456789, id + 1) |
==================================
1.234567910432816e-01 |
1.123456791043282e+00 |
1.234567910432816e-01 |
1.123456791043282e+00 |
1.123456791043282e+00 |
3.123456791043282e+00 |
6.123456791043282e+00 |
1.123456791043282e+00 |
1.234567910432816e-01 |
1.123456791043282e+00 |
0.123456791043282 |
1.12345679104328 |
0.123456791043282 |
1.12345679104328 |
1.12345679104328 |
3.12345679104328 |
6.12345679104328 |
1.12345679104328 |
0.123456791043282 |
1.12345679104328 |
taos> select MOD(current, id + 1) from ts_4893.meters order by ts limit 10
mod(current, id + 1) |
@ -94,16 +94,16 @@ taos> select MOD(current, 1) from ts_4893.meters order by ts limit 10
taos> select MOD(sqrt(current), abs(id + 1)) from ts_4893.meters order by ts limit 10
mod(sqrt(current), abs(id + 1)) |
==================================
2.634337159700784e-01 |
9.281394021770111e-01 |
1.296964830944782e-01 |
3.351566768190027e+00 |
3.272002495118848e+00 |
2.916847677517688e+00 |
3.097741066924800e+00 |
3.310891102586806e+00 |
3.350522322288470e+00 |
3.215120509901375e+00 |
0.263433715970078 |
0.928139402177011 |
0.129696483094478 |
3.35156676819003 |
3.27200249511885 |
2.91684767751769 |
3.0977410669248 |
3.31089110258681 |
3.35052232228847 |
3.21512050990137 |
taos> select mod(10, -3)
mod(10, -3) |

1 taos> select MOD(10.55, 3)
42 mod(87654321.123456789, id + 1) |
43 ==================================
44 1.234567910432816e-01 | 0.123456791043282 |
45 1.123456791043282e+00 | 1.12345679104328 |
46 1.234567910432816e-01 | 0.123456791043282 |
47 1.123456791043282e+00 | 1.12345679104328 |
48 1.123456791043282e+00 | 1.12345679104328 |
49 3.123456791043282e+00 | 3.12345679104328 |
50 6.123456791043282e+00 | 6.12345679104328 |
51 1.123456791043282e+00 | 1.12345679104328 |
52 1.234567910432816e-01 | 0.123456791043282 |
53 1.123456791043282e+00 | 1.12345679104328 |
54 taos> select MOD(current, id + 1) from ts_4893.meters order by ts limit 10
55 mod(current, id + 1) |
56 ============================
57 0.649999618530273 |
58 0.574000358581543 |
59 0.795000076293945 |
60 3.23299980163574 |
61 0.706000328063965 |
62 2.50800037384033 |
63 2.5959997177124 |
64 2.96199989318848 |
65 2.22599983215332 |
66 0.336999893188477 |
67 taos> select MOD(current, 1) from ts_4893.meters order by ts limit 10
94 mod(10, -3) |
95 ============================
96 1 |
97 taos> select mod(10, 3)
98 mod(10, 3) |
99 ============================
100 1 |
101 taos> select mod(id, 3) from ts_4893.d0 order by ts limit 10
102 mod(id, 3) |
103 ============================
104 0 |
105 1 |
106 2 |
107 0 |
108 1 |
109 2 |

View File

@ -190,5 +190,5 @@ taos> select voltage / pi() from ts_4893.meters limit 1
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 |
====================================================================
0 | 3.141592653589793e+00 |
0 | 3.14159265358979 |

Can't render this file because it has a wrong number of fields in line 90.

View File

@ -201,7 +201,7 @@ taos> select ABS(POSITION('aaa' IN 'aaaaaaaaa'))
taos> select POW(POSITION('aaa' IN 'aaaaaaaaa'), 2)
pow(position('aaa' in 'aaaaaaaaa'), 2) |
=========================================
1.000000000000000e+00 |
1 |
taos> select position('t' in 'taos')
position('t' in 'taos') |

Can't render this file because it has a wrong number of fields in line 22.

View File

@ -50,12 +50,12 @@ taos> select rand(-1)
taos> select rand(12345678901234567890)
rand(12345678901234567890) |
=============================
2.008294813338805e-01 |
0.20082948133388 |
taos> select rand(-12345678901234567890)
rand(-12345678901234567890) |
==============================
8.401877171547095e-01 |
0.84018771715471 |
taos> select rand(12345), rand(12345)
rand(12345) | rand(12345) |

Can't render this file because it has a wrong number of fields in line 60.

View File

@ -67,12 +67,12 @@ taos> select ROUND(10.55, 1) + 1
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), |
===================================================================
1.230000000000000e+02 |
12 |
taos> select ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(ROUND(123456789.123456789, -1), -2), -3), -4), -5), -6))
round(round(round(round(round(round(round(123456789.123456789, - |
===================================================================
1.230000000000000e+08 |
12300000 |
taos> select ROUND(current) from ts_4893.meters order by ts limit 20
round(current) |
@ -101,16 +101,16 @@ taos> select ROUND(current) from ts_4893.meters order by ts limit 20
taos> select ROUND(87654321.123456789, id) from ts_4893.meters order by ts limit 10
round(87654321.123456789, id) |
================================
8.765432100000000e+07 |
8.765432109999999e+07 |
8.765432112000000e+07 |
8.765432112300000e+07 |
8.765432112350000e+07 |
8.765432112345999e+07 |
8.765432112345700e+07 |
8.765432112345681e+07 |
8.765432112345679e+07 |
8.765432112345679e+07 |
87654321 |
87654321.1 |
87654321.12 |
87654321.123 |
87654321.1235 |
87654321.12346 |
87654321.123457 |
87654321.1234568 |
87654321.1234568 |
87654321.1234568 |
taos> select ROUND(current, id) from ts_4893.meters order by ts limit 10
round(current, id) |
@ -286,7 +286,7 @@ taos> select round(voltage, -1) from ts_4893.meters limit 1
taos> select round(current * voltage, 2) from ts_4893.meters limit 1
round(current * voltage, 2) |
==============================
2.353650000000000e+03 |
2353.65 |
taos> select round(abs(voltage), 2) from ts_4893.meters limit 1
round(abs(voltage), 2) |

1 taos> select ROUND(10.55, 3)
67 11 |
68 11 |
69 9 |
70 10 |
71 11 |
72 11 |
73 10 |
74 11 |
75 9 |
76 11 |
77 8 |
78 12 |
101 8.6 |
102 9.8 |
103 11.233 |
104 10.706 |
105 8.508 |
106 9.596 |
107 10.962 |
108 11.226 |
109 10.337 |
110 taos> select ROUND(current, 1) from ts_4893.meters order by ts limit 10
111 round(current, 1) |
112 =======================
113 10.7 |
114 8.6 |
115 9.8 |
116 11.2 |
286 round(cast(5 as tinyint unsigned), 1) |
287 ========================================
288 5 |
289 taos> select round(cast(50 as smallint unsigned), 1);
290 round(cast(50 as smallint unsigned), 1) |
291 ==========================================
292 50 |

View File

@ -164,7 +164,7 @@ taos> select sign(cast(1 as bigint unsigned))
taos> select sign(cast(1 as float))
sign(cast(1 as float)) |
=========================
1.0000000e+00 |
1 |
taos> select sign(cast(1 as double))
sign(cast(1 as double)) |
@ -316,30 +316,30 @@ taos> select sign(current) from ts_4893.meters order by ts limit 10
taos> select sign(cast(current as float)) from ts_4893.d0 order by ts limit 10
sign(cast(current as float)) |
===============================
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
taos> select sign(cast(current as float)) from ts_4893.meters order by ts limit 10
sign(cast(current as float)) |
===============================
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1.0000000e+00 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
taos> select sign(null)
sign(null) |

Can't render this file because it has a wrong number of fields in line 239.

View File

@ -109,17 +109,17 @@ taos> select stddev_pop(total_voltage) from (select sum(voltage) as total_voltag
taos> select round(stddev_pop(current), 2) from ts_4893.meters
round(stddev_pop(current), 2) |
================================
1.150000000000000e+00 |
1.15 |
taos> select pow(stddev_pop(current), 2) from ts_4893.meters
pow(stddev_pop(current), 2) |
==============================
1.332500071133751e+00 |
1.33250007113375 |
taos> select log(stddev_pop(voltage) + 1) from ts_4893.meters
log(stddev_pop(voltage) + 1) |
===============================
1.354922290183882e+00 |
1.35492229018388 |
taos> select groupid, stddev_pop(voltage) from ts_4893.meters group by groupid order by groupid
groupid | stddev_pop(voltage) |

Can't render this file because it has a wrong number of fields in line 109.

View File

@ -47,40 +47,40 @@ taos> select TRUNCATE(10.55, 1) + 1
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 |
===================================================================
1.231230000000000e+02 |
123.12 |
taos> select TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(TRUNCATE(123456789.123456789, -1), -2), -3), -4), -5), -6), -7)
truncate(truncate(truncate(truncate(truncate(truncate(truncate(1 |
===================================================================
1.200000000000000e+08 |
12000000 |
taos> select TRUNCATE(87654321.123456789, id) from ts_4893.meters order by ts limit 10
truncate(87654321.123456789, id) |
===================================
8.765432100000000e+07 |
8.765432109999999e+07 |
8.765432112000000e+07 |
8.765432112300000e+07 |
8.765432112340000e+07 |
8.765432112345000e+07 |
8.765432112345600e+07 |
8.765432112345670e+07 |
8.765432112345679e+07 |
8.765432112345679e+07 |
87654321 |
87654321.1 |
87654321.12 |
87654321.123 |
87654321.1234 |
87654321.12345 |
87654321.123456 |
87654321.1234567 |
87654321.1234568 |
87654321.1234568 |
taos> select TRUNCATE(current, id) from ts_4893.meters order by ts limit 10
truncate(current, id) |
========================
1.0000000e+01 |
8.5000000e+00 |
9.7900000e+00 |
1.1233000e+01 |
1.0706000e+01 |
8.5080004e+00 |
9.5959997e+00 |
1.0962000e+01 |
1.1226000e+01 |
1.0337000e+01 |
10 |
8.5 |
9.79 |
11.233 |
10.706 |
8.508 |
9.596 |
10.962 |
11.226 |
10.337 |
taos> select TRUNCATE(current, 1) from ts_4893.meters order by ts limit 10
truncate(current, 1) |
@ -144,26 +144,26 @@ taos> select TRUNC(10.55, 1) + 1
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), |
===================================================================
1.231230000000000e+02 |
123.12 |
taos> select TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(TRUNC(123456789.123456789, -1), -2), -3), -4), -5), -6), -7)
trunc(trunc(trunc(trunc(trunc(trunc(trunc(123456789.123456789, - |
===================================================================
1.200000000000000e+08 |
12000000 |
taos> select TRUNC(87654321.123456789, id) from ts_4893.meters order by ts limit 10
trunc(87654321.123456789, id) |
================================
8.765432100000000e+07 |
8.765432109999999e+07 |
8.765432112000000e+07 |
8.765432112300000e+07 |
8.765432112340000e+07 |
8.765432112345000e+07 |
8.765432112345600e+07 |
8.765432112345670e+07 |
8.765432112345679e+07 |
8.765432112345679e+07 |
87654321 |
87654321.1 |
87654321.12 |
87654321.123 |
87654321.1234 |
87654321.12345 |
87654321.123456 |
87654321.1234567 |
87654321.1234568 |
87654321.1234568 |
taos> select TRUNC(current, id) from ts_4893.meters order by ts limit 10
trunc(current, id) |
@ -289,7 +289,7 @@ taos> select truncate(100.9876, 2)
taos> select truncate(99999999999999.9999, 2)
truncate(99999999999999.9999, 2) |
===================================
1.000000000000000e+14 |
100000000000000 |
taos> select truncate(-5.678, 2)
truncate(-5.678, 2) |
@ -314,7 +314,7 @@ taos> select truncate(phase, 3) from ts_4893.meters limit 1
taos> select truncate(voltage + current, 2) from ts_4893.meters limit 1
truncate(voltage + current, 2) |
=================================
2.316400000000000e+02 |
231.64 |
taos> select truncate(voltage, -1) from ts_4893.meters limit 1
truncate(voltage, -1) |
@ -329,7 +329,7 @@ taos> select round(truncate(voltage, 1), 2) from ts_4893.meters limit 1
taos> select truncate(abs(current), 1) from ts_4893.meters limit 1
truncate(abs(current), 1) |
============================
1.0600000e+01 |
10.6 |
taos> select truncate(exp(phase), 2) from ts_4893.meters limit 1
truncate(exp(phase), 2) |

1 taos> select TRUNCATE(10.55, 3)
47 ===================================
48 8.765432100000000e+07 | 87654321 |
49 8.765432109999999e+07 | 87654321.1 |
50 8.765432112000000e+07 | 87654321.12 |
51 8.765432112300000e+07 | 87654321.123 |
52 8.765432112340000e+07 | 87654321.1234 |
53 8.765432112345000e+07 | 87654321.12345 |
54 8.765432112345600e+07 | 87654321.123456 |
55 8.765432112345670e+07 | 87654321.1234567 |
56 8.765432112345679e+07 | 87654321.1234568 |
57 8.765432112345679e+07 | 87654321.1234568 |
58 taos> select TRUNCATE(current, id) from ts_4893.meters order by ts limit 10
59 truncate(current, id) |
60 ========================
61 1.0000000e+01 | 10 |
62 8.5000000e+00 | 8.5 |
63 9.7900000e+00 | 9.79 |
64 1.1233000e+01 | 11.233 |
65 1.0706000e+01 | 10.706 |
66 8.5080004e+00 | 8.508 |
67 9.5959997e+00 | 9.596 |
68 1.0962000e+01 | 10.962 |
69 1.1226000e+01 | 11.226 |
70 1.0337000e+01 | 10.337 |
71 taos> select TRUNCATE(current, 1) from ts_4893.meters order by ts limit 10
72 truncate(current, 1) |
73 =======================
74 10.6 |
75 8.5 |
76 9.7 |
77 11.2 |
78 10.7 |
79 8.5 |
80 9.5 |
81 10.9 |
82 11.2 |
83 10.3 |
84 taos> select TRUNC(10.55, 3)
85 trunc(10.55, 3) |
86 ============================
144 10 |
145 8.5 |
146 9.79 |
147 11.233 |
148 10.706 |
149 8.508 |
150 9.596 |
151 10.962 |
152 11.226 |
153 10.337 |
154 taos> select TRUNC(current, 1) from ts_4893.meters order by ts limit 10
155 trunc(current, 1) |
156 =======================
157 10.6 |
158 8.5 |
159 9.7 |
160 11.2 |
161 10.7 |
162 8.5 |
163 9.5 |
164 10.9 |
165 11.2 |
166 10.3 |
167 taos> select truncate(99.99, 3)
168 truncate(99.99, 3) |
169 ============================
289
290
291
292
293
294
295
314
315
316
317
318
319
320
329
330
331
332
333
334
335

View File

@ -99,7 +99,7 @@ taos> select var_pop(total_voltage) from (select sum(voltage) as total_voltage f
taos> select round(var_pop(current), 2) from ts_4893.meters
round(var_pop(current), 2) |
=============================
1.330000000000000e+00 |
1.33 |
taos> select pow(var_pop(current), 2) from ts_4893.meters
pow(var_pop(current), 2) |

Can't render this file because it has a wrong number of fields in line 99.

View File

@ -671,12 +671,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 = snprintf(buf, LENGTH, "%*.*g", width, FLT_DIG, GET_FLOAT_VAL(val));
if (n > width) {
printf("%*.7e", width, GET_FLOAT_VAL(val));
} else {
printf("%s", buf);
}
snprintf(buf, LENGTH, "%*.*g", width, FLT_DIG, GET_FLOAT_VAL(val));
printf("%s", buf);
}
break;
case TSDB_DATA_TYPE_DOUBLE:
@ -684,12 +680,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 = 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);
}
snprintf(buf, LENGTH, "%*.*g", width, DBL_DIG, GET_DOUBLE_VAL(val));
printf("%*s", width, buf);
}
break;
case TSDB_DATA_TYPE_VARBINARY: {