Skip to content

Commit b985a71

Browse files
authored
Merge pull request ClickHouse#78247 from yariks5s/fix-logical-error-transform
Fix a logical error for function `transform`
2 parents ac48846 + b0edd74 commit b985a71

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/Functions/transform.cpp

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

164164
ColumnPtr in_cast = 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)