Open davidshiz opened 1 year ago
~~ it's about data precision. ~~ with duplication columns, it seems output a correct result.
mysql> SELECT d1, d2 FROM cs1 UNION SELECT d2, d3 FROM cs1;
+-----------------+----------------------+
| d1 | d2 |
+-----------------+----------------------+
| 125.0000000000 | 1.25000000000000000 |
| -125.0000000000 | -1.25000000000000000 |
| 1.2500000000 | 0.12500000000000000 |
| -1.2500000000 | -0.12500000000000000 |
+-----------------+----------------------+
4 rows in set (0.00 sec)
add query table: ./test/cs1 T:-1 = TABLE_ALIAS(T:0,"cs1") T:-2 = TMP_TABLE(T:4294967295) VC:-2.0 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:0)) A:-1 = T:-2.ADD_COLUMN(VC:-2.0,LIST,"d1","ALL") A:-2 = T:-2.ADD_COLUMN(VC:-2.0,LIST,"d1","ALL") VC:-2.1 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:1)) A:-3 = T:-2.ADD_COLUMN(VC:-2.1,LIST,"d2","ALL") T:-2.APPLY_CONDS() T:-3 = TABLE_ALIAS(T:0,"cs1") T:-4 = TMP_TABLE(T:4294967293) VC:-4.0 = CREATE_VC(T:-4,PHYS_COL(T:-3,A:1)) A:-1 = T:-4.ADD_COLUMN(VC:-4.0,LIST,"d2","ALL") VC:-4.1 = CREATE_VC(T:-4,PHYS_COL(T:-3,A:2)) A:-2 = T:-4.ADD_COLUMN(VC:-4.1,LIST,"d3","ALL") A:-3 = T:-4.ADD_COLUMN(VC:-4.1,LIST,"d3","ALL") T:-4.APPLY_CONDS() T:-2 = UNION(T:-2,T:-4,0) RESULT(T:-2) Result: 4 Costtime(ms): 2
the tye of the 3rd of output column is : decimal(17,17). and in union operation.
The column type of output is determined by combination of two types of columns.
For example: col1: decimal(17), and the col3 is decmial(17,10), and the type of output column of union
is decmial(17,17). But on stonedb, now, the precision of decimal type cannot be higher than 18. Therefore, the 59.46744073709551616
means that it overflows
the val of the output is : 125 * 100000000000000000. Therefore, it overflows with type of int64_t
.
On StoneDB, the precision for DECIMAL numbers cannot be higher than 18. For example, if you specify decimal(19) in your code, an error will be reported. DECIMAL(6, 2) indicates that up to 6 places are supported at the left of the decimal and up to 2 at the right, and thus the value range is [-9999.99, 9999.99].
ref: https://stonedb.io/docs/SQL-reference/data-types
mysql> INSERT INTO cs1 VALUES (-126, -1.26, 125);
ERROR 1264 (22003): Out of range value for column 'd3' at row 1
It is recommended to give a prompt, prompting super precision after union
Have you read the Contributing Guidelines on issues?
Please confirm if bug report does NOT exists already ?
Describe the problem
Expected behavior
How To Reproduce
Environment
Are you interested in submitting a PR to solve the problem?