Skip to content

Commit 4085934

Browse files
Merge pull request ClickHouse#92434 from ClickHouse/backport/25.8/92351
Backport ClickHouse#92351 to 25.8: Fix logical error caused by `Nothing` type in `caseWithExpression` function
2 parents 092655c + 67636fb commit 4085934

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

src/Functions/caseWithExpression.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class FunctionCaseWithExpression : public IFunction
2929
bool isVariadic() const override { return true; }
3030
bool useDefaultImplementationForConstants() const override { return false; }
3131
bool useDefaultImplementationForNulls() const override { return false; }
32-
bool useDefaultImplementationForNothing() const override { return false; }
3332
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
3433
size_t getNumberOfArguments() const override { return 0; }
3534
String getName() const override { return name; }
@@ -62,14 +61,6 @@ class FunctionCaseWithExpression : public IFunction
6261
/// Helper function to implement CASE WHEN equality semantics where NULL = NULL is true
6362
ColumnPtr caseWhenEquals(const ColumnWithTypeAndName & expr, const ColumnWithTypeAndName & when_value, size_t input_rows_count) const
6463
{
65-
// handle Nothing type - it's an empty type that can't contain any values
66-
// if either argument is Nothing, the result should be an empty column
67-
if (expr.type->onlyNull() || when_value.type->onlyNull())
68-
{
69-
// return a constant false column
70-
return DataTypeUInt8().createColumnConst(input_rows_count, 0u);
71-
}
72-
7364
// for CASE WHEN semantics, NULL should match NULL
7465
// we need: if (isNull(expr)) then (isNull(when)) else if (isNull(when)) then 0 else (expr = when)
7566

tests/queries/0_stateless/03390_non_constant_case.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,10 @@ SELECT caseWithExpression(
5959
materialize(NULL),
6060
NULL,
6161
NULL
62-
); -- { serverError ILLEGAL_COLUMN }
62+
); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
63+
64+
SELECT caseWithExpression('C', 'A', true, 'B', false); -- { serverError BAD_ARGUMENTS }
65+
66+
SELECT caseWithExpression(1, assumeNotNull(materialize(NULL)), 1, 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
67+
68+
SELECT count() WHERE caseWithExpression(1, assumeNotNull(materialize(NULL)), 1, 1); -- { serverError ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER }

tests/queries/0_stateless/03444_case_with_expression_exception.reference

Whitespace-only changes.

tests/queries/0_stateless/03444_case_with_expression_exception.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)