Merge pull request #53742 from aiven-sal/aiven-sal/fix_53187

transform: correctly handle default column with multiple rows
This commit is contained in:
Alexey Milovidov 2023-08-29 21:57:59 +03:00 committed by GitHub
commit 9b74939110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 2 deletions

View File

@ -163,7 +163,16 @@ namespace
ColumnPtr default_non_const;
if (!cache.default_column && arguments.size() == 4)
{
default_non_const = castColumn(arguments[3], result_type);
if (in->size() > default_non_const->size())
{
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"Fourth argument of function {} must be a constant or a column at least as big as the second and third arguments",
getName());
}
}
ColumnPtr in_casted = arguments[0].column;
if (arguments.size() == 3)
@ -490,7 +499,7 @@ namespace
else if (cache.default_column)
column_result.insertFrom(*cache.default_column, 0);
else if (default_non_const)
column_result.insertFrom(*default_non_const, 0);
column_result.insertFrom(*default_non_const, i);
else
column_result.insertFrom(in_casted, i);
}

View File

@ -30,3 +30,9 @@ sep4
sep5
8000
sep6
issue #53187
0 1 1
1 0 0
-
0 0 0
1 1 1

View File

@ -33,3 +33,16 @@ select 'sep6';
SELECT transform(-9223372036854775807, [-1], [toDecimal32(1024, 3)]) FROM system.numbers LIMIT 7; -- { serverError BAD_ARGUMENTS }
SELECT [NULL, NULL, NULL, NULL], transform(number, [2147483648], [toDecimal32(1, 2)]) AS x FROM numbers(257) WHERE materialize(10); -- { serverError BAD_ARGUMENTS }
SELECT transform(-2147483649, [1], [toDecimal32(1, 2)]) GROUP BY [1] WITH TOTALS; -- { serverError BAD_ARGUMENTS }
SELECT 'issue #53187';
SELECT
CAST(number, 'String') AS v2,
caseWithExpression('x', 'y', 0, cond2) AS cond1,
toNullable('0' = v2) AS cond2
FROM numbers(2);
SELECT '-';
SELECT
CAST(number, 'String') AS v2,
caseWithExpression('x', 'y', 0, cond2) AS cond1,
toNullable('1' = v2) AS cond2
FROM numbers(2);

View File

@ -5,5 +5,5 @@ ONE
a
a
\N 0 \N 0 \N
1 1 1 \N 1 1
1 1 1 1 1 1
a \N 3 3 3 3