Skip to content

Commit

Permalink
Merge pull request ClickHouse#61491 from ClickHouse/definitive-cast
Browse files Browse the repository at this point in the history
A definitive guide to CAST
  • Loading branch information
alexey-milovidov authored Mar 16, 2024
2 parents 805a4b2 + 65eb6f1 commit 4dc5319
Show file tree
Hide file tree
Showing 4 changed files with 426 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Functions/formatDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1832,10 +1832,10 @@ using FunctionFromUnixTimestampInJodaSyntax = FunctionFormatDateTimeImpl<NameFro
REGISTER_FUNCTION(FormatDateTime)
{
factory.registerFunction<FunctionFormatDateTime>();
factory.registerAlias("DATE_FORMAT", FunctionFormatDateTime::name);
factory.registerAlias("DATE_FORMAT", FunctionFormatDateTime::name, FunctionFactory::CaseInsensitive);

factory.registerFunction<FunctionFromUnixTimestamp>();
factory.registerAlias("FROM_UNIXTIME", FunctionFromUnixTimestamp::name);
factory.registerAlias("FROM_UNIXTIME", FunctionFromUnixTimestamp::name, FunctionFactory::CaseInsensitive);

factory.registerFunction<FunctionFormatDateTimeInJodaSyntax>();
factory.registerFunction<FunctionFromUnixTimestampInJodaSyntax>();
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/parseDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ namespace
REGISTER_FUNCTION(ParseDateTime)
{
factory.registerFunction<FunctionParseDateTime>();
factory.registerAlias("TO_UNIXTIME", FunctionParseDateTime::name);
factory.registerAlias("TO_UNIXTIME", FunctionParseDateTime::name, FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionParseDateTimeOrZero>();
factory.registerFunction<FunctionParseDateTimeOrNull>();
factory.registerAlias("str_to_date", FunctionParseDateTimeOrNull::name, FunctionFactory::CaseInsensitive);
Expand Down
77 changes: 77 additions & 0 deletions tests/queries/0_stateless/03011_definitive_guide_to_cast.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
123
2009-02-14 00:31:30
[1,2,3]
123 Nullable(UInt8)
\N Nullable(UInt8)
1
255
['Hello','wo\'rld\\']
Hello wo\\\'rld\\\\
wo\'rld\\ wo\\\'rld\\\\
133 210
210
[123,456]
1 -1
[] [] Array(Nothing) Array(Array(Array(Tuple(UInt64, String))))
1970-01-01 01:00:00
2009-02-14 00:31:30.123456
1970-01-01 00:59:59.888889
2009-02-14 00:31:30
1970-01-01 01:00:00
2299-12-31 23:59:59.000000
2009-02-14
2009-02-14
123\0\0
123
123
123
123
123
123
123
123
123
123
String 123
123 UInt8
200 UInt8
123
123
1.1
1.10000000000000016387
18446744073709551615
[1.1,2.3]
[1.10000000000000016387,2.29999999999999967236]
Row 1:
──────
CAST('1.1', 'Decimal(30, 20)'): 1.1
CAST('1.1', 'Decimal(30, 20)'): 1.1
CAST(plus(1, 1), 'UInt8'): 2
-1
\N
0
255
123
Hello\0\0\0\0\0
Hello\0\0\0\0\0
123.45
2024-04-25 01:02:03
2024-04-25 01:02:03.000000
2024-04-25 01:02:03
2024-04-25 01:02:03.456789
2024-03-16 11:01:25
2024-03-16 19:01:25
2024-03-16 19:01:25
2024-03-16 11:01:25
123 \N \N \N
123 0 0 0
Nullable(UInt8) UInt8
123
123
123
\N
2024-04-25 2024-01-01 02:03:04 1 12
2024-04-25 2024-01-01 02:03:04.000000 2009-02-14 00:31:30
2024-04-25 2024-01-01 02:03:04.000000 2009-02-14 00:31:30
1986-04-25 13:00:00
14
Loading

0 comments on commit 4dc5319

Please sign in to comment.