Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for #16399 #48439

Merged
merged 6 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
120 changes: 120 additions & 0 deletions tests/queries/0_stateless/00700_to_decimal_or_something_1.reference.j2
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions tests/queries/0_stateless/00700_to_decimal_or_something_1.sql.j2
Original file line number Diff line number Diff line change
@@ -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 -%}