Merge pull request #48439 from den-crane/testtoFloat64OrNull

test for #16399
This commit is contained in:
Alexey Milovidov 2023-04-12 22:11:47 +03:00 committed by GitHub
commit d8568b188a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 152 additions and 0 deletions

View File

@ -0,0 +1,120 @@
---- toDecimal32 ----
54.1234
1.1111
---- toDecimal64 ----
54.1234
1.1111
---- toDecimal128 ----
54.1234
1.1111
---- toDecimal256 ----
54.1234
1.1111
---- toDecimal32OrDefault ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal32OrNull ----
54.1234
1.1111
\N
\N
\N
\N
\N
\N
---- toDecimal32OrZero ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal64OrDefault ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal64OrZero ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal64OrNull ----
54.1234
1.1111
\N
\N
\N
\N
\N
\N
---- toDecimal128OrDefault ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal128OrNull ----
54.1234
1.1111
\N
\N
\N
\N
\N
\N
---- toDecimal128OrZero ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal256OrDefault ----
54.1234
1.1111
0
0
0
0
0
0
---- toDecimal256OrNull ----
54.1234
1.1111
\N
\N
\N
\N
\N
\N
---- toDecimal256OrZero ----
54.1234
1.1111
0
0
0
0
0
0

View File

@ -0,0 +1,32 @@
{% for func in [ "toDecimal32", "toDecimal64", "toDecimal128", "toDecimal256" ] -%}
SELECT '---- {{ func }} ----';
SELECT {{ func }} ('54.1234567', 4);
SELECT {{ func }} ('1.1111111111111111111111111111111111111', 4);
SELECT {{ func }} ('x123', 4); -- { serverError CANNOT_PARSE_TEXT }
SELECT {{ func }} ('', 4); -- { serverError ATTEMPT_TO_READ_AFTER_EOF }
SELECT {{ func }} ('\0', 4); -- { serverError CANNOT_PARSE_TEXT }
SELECT {{ func }} ('\0\0\0\0\0', 4); -- { serverError CANNOT_PARSE_TEXT }
SELECT {{ func }} ('\n\t\r', 4); -- { serverError CANNOT_PARSE_TEXT }
SELECT {{ func }} ('\'', 4); -- { serverError CANNOT_PARSE_TEXT }
{% endfor -%}
{% for func in [ "toDecimal32OrDefault", "toDecimal32OrNull", "toDecimal32OrZero",
"toDecimal64OrDefault", "toDecimal64OrZero", "toDecimal64OrNull",
"toDecimal128OrDefault", "toDecimal128OrNull", "toDecimal128OrZero",
"toDecimal256OrDefault", "toDecimal256OrNull", "toDecimal256OrZero" ] -%}
SELECT '---- {{ func }} ----';
SELECT {{ func }} ('54.1234567', 4);
SELECT {{ func }} ('1.1111111111111111111111111111111111111', 4);
SELECT {{ func }} ('x123', 4);
SELECT {{ func }} ('', 4);
SELECT {{ func }} ('\0', 4);
SELECT {{ func }} ('\0\0\0\0\0', 4);
SELECT {{ func }} ('\n\t\r', 4);
SELECT {{ func }} ('\'', 4);
{% endfor -%}