Fixes for FunctionConversion implementation for nulls

This commit is contained in:
vdimir 2021-07-12 16:04:59 +03:00
parent b4c6a17eb2
commit c938a53e88
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
5 changed files with 12 additions and 1 deletions

View File

@ -693,7 +693,10 @@ struct ConvertImpl<FromDataType, std::enable_if_t<!std::is_same_v<FromDataType,
const DateLUTImpl * time_zone = nullptr;
/// For argument of DateTime type, second argument with time zone could be specified.
if constexpr (std::is_same_v<FromDataType, DataTypeDateTime> || std::is_same_v<FromDataType, DataTypeDateTime64>)
time_zone = &extractTimeZoneFromFunctionArguments(arguments, 1, 0);
{
auto non_null_args = createBlockWithNestedColumns(arguments);
time_zone = &extractTimeZoneFromFunctionArguments(non_null_args, 1, 0);
}
if (const auto col_from = checkAndGetColumn<ColVecType>(col_with_type_and_name.column.get()))
{
@ -1519,6 +1522,9 @@ private:
throw Exception{"Function " + getName() + " expects at least 1 argument",
ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION};
if (result_type->onlyNull())
return result_type->createColumnConstWithDefaultValue(input_rows_count);
const DataTypePtr from_type = removeNullable(arguments[0].type);
ColumnPtr result_column;

View File

@ -1,5 +1,6 @@
1
\N
\N
0
0
0 0

View File

@ -22,6 +22,8 @@ GLOBAL INNER JOIN
-- query from fuzzer
SELECT toDateTime64(toString(toString('0000-00-00 00:00:000000-00-00 00:00:00', toDateTime64(toDateTime64('655.36', -2, NULL)))), NULL) FROM t1_00850 GLOBAL INNER JOIN (SELECT toDateTime64(toDateTime64('6553.6', '', NULL), NULL), * FROM (SELECT * FROM t2_00850) INNER JOIN (SELECT toDateTime64('6553.7', 1024, NULL), * FROM t1_00850) USING (dummy)) USING (dummy);
SELECT toString('0000-00-00 00:00:000000-00-00 00:00:00', toDateTime64(toDateTime64('655.36', -2, NULL)));
DROP TABLE t_local;
DROP TABLE t1_00850;
DROP TABLE t2_00850;

View File

@ -2,3 +2,4 @@ A
\N
A
\N
\N

View File

@ -3,4 +3,5 @@ create table test_enum (c Nullable(Enum16('A' = 1, 'B' = 2))) engine Log;
insert into test_enum values (1), (NULL);
select * from test_enum;
select toString(c) from test_enum;
select toString('aaaa', NULL);
drop table test_enum;