Skip to content

Commit 419ef2b

Browse files
Backport #78247 to 24.8: Fix a logical error for function transform
1 parent f0ecd10 commit 419ef2b

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/Functions/transform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ namespace
150150
ColumnPtr default_non_const;
151151
if (!cache.default_column && arguments.size() == 4)
152152
{
153-
default_non_const = castColumn(arguments[3], result_type);
154-
if (in->size() > default_non_const->size())
153+
if (arguments[1].column.get()->size() > arguments[3].column.get()->size() || arguments[2].column.get()->size() > arguments[3].column.get()->size())
155154
{
156155
throw Exception(
157-
ErrorCodes::LOGICAL_ERROR,
158-
"Fourth argument of function {} must be a constant or a column at least as big as the second and third arguments",
156+
ErrorCodes::BAD_ARGUMENTS,
157+
"Fourth argument of function {} must be a constant or at least as big as the second and third arguments",
159158
getName());
160159
}
160+
default_non_const = castColumn(arguments[3], result_type);
161161
}
162162

163163
ColumnPtr in_casted = arguments[0].column;

tests/queries/0_stateless/03340_transform_logical_error_fix.reference

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SET enable_analyzer = 1;
2+
3+
SELECT transform(NULL, ['', ''], ['', ''], *)
4+
FROM
5+
(
6+
SELECT NULL
7+
); -- { serverError BAD_ARGUMENTS }

0 commit comments

Comments
 (0)