mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #13226 from ClickHouse/fix-if-nullable-cond-return-type
Fix function if with nullable constexpr as cond that is not literal NULL
This commit is contained in:
commit
851e1a70d3
@ -701,20 +701,14 @@ private:
|
|||||||
|
|
||||||
if (cond_is_true)
|
if (cond_is_true)
|
||||||
{
|
{
|
||||||
if (result_column.type->equals(*column1.type))
|
result_column.column = castColumn(column1, result_column.type);
|
||||||
{
|
|
||||||
result_column.column = std::move(column1.column);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (cond_is_false || cond_is_null)
|
else if (cond_is_false || cond_is_null)
|
||||||
{
|
{
|
||||||
if (result_column.type->equals(*column2.type))
|
result_column.column = castColumn(column2, result_column.type);
|
||||||
{
|
|
||||||
result_column.column = std::move(column2.column);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (const auto * nullable = checkAndGetColumn<ColumnNullable>(*not_const_condition))
|
if (const auto * nullable = checkAndGetColumn<ColumnNullable>(*not_const_condition))
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,7 @@ value vs value
|
|||||||
0 1 1 Int64 UInt8 Int64
|
0 1 1 Int64 UInt8 Int64
|
||||||
0 1 1 Int64 UInt16 Int64
|
0 1 1 Int64 UInt16 Int64
|
||||||
0 1 1 Int64 UInt32 Int64
|
0 1 1 Int64 UInt32 Int64
|
||||||
|
0 1 1 Int64 Decimal(9, 0) Decimal(18, 0)
|
||||||
0 1 1 Int64 Decimal(18, 0) Decimal(18, 0)
|
0 1 1 Int64 Decimal(18, 0) Decimal(18, 0)
|
||||||
0 1 1 Int64 Decimal(38, 0) Decimal(38, 0)
|
0 1 1 Int64 Decimal(38, 0) Decimal(38, 0)
|
||||||
0 1 1 UInt8 Int8 Int16
|
0 1 1 UInt8 Int8 Int16
|
||||||
@ -80,12 +81,15 @@ value vs value
|
|||||||
0 1 1 UInt32 UInt64 UInt64
|
0 1 1 UInt32 UInt64 UInt64
|
||||||
0 1 1 UInt32 Float32 Float64
|
0 1 1 UInt32 Float32 Float64
|
||||||
0 1 1 UInt32 Float64 Float64
|
0 1 1 UInt32 Float64 Float64
|
||||||
|
0 1 1 UInt32 Decimal(9, 0) Decimal(18, 0)
|
||||||
0 1 1 UInt32 Decimal(18, 0) Decimal(18, 0)
|
0 1 1 UInt32 Decimal(18, 0) Decimal(18, 0)
|
||||||
0 1 1 UInt32 Decimal(38, 0) Decimal(38, 0)
|
0 1 1 UInt32 Decimal(38, 0) Decimal(38, 0)
|
||||||
0 1 1 UInt64 UInt8 UInt64
|
0 1 1 UInt64 UInt8 UInt64
|
||||||
0 1 1 UInt64 UInt16 UInt64
|
0 1 1 UInt64 UInt16 UInt64
|
||||||
0 1 1 UInt64 UInt32 UInt64
|
0 1 1 UInt64 UInt32 UInt64
|
||||||
0 1 1 UInt64 UInt64 UInt64
|
0 1 1 UInt64 UInt64 UInt64
|
||||||
|
0 1 1 UInt64 Decimal(9, 0) Decimal(38, 0)
|
||||||
|
0 1 1 UInt64 Decimal(18, 0) Decimal(38, 0)
|
||||||
0 1 1 UInt64 Decimal(38, 0) Decimal(38, 0)
|
0 1 1 UInt64 Decimal(38, 0) Decimal(38, 0)
|
||||||
1970-01-01 1970-01-02 1970-01-02 Date Date Date
|
1970-01-01 1970-01-02 1970-01-02 Date Date Date
|
||||||
2000-01-01 2000-01-01 00:00:01 2000-01-01 00:00:01 Date DateTime(\'Europe/Moscow\') DateTime
|
2000-01-01 2000-01-01 00:00:01 2000-01-01 00:00:01 Date DateTime(\'Europe/Moscow\') DateTime
|
||||||
|
@ -66,7 +66,7 @@ SELECT toInt64(0) AS x, toFloat64(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x)
|
|||||||
SELECT toInt64(0) AS x, toDate(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toInt64(0) AS x, toDate(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
||||||
SELECT toInt64(0) AS x, toDateTime(1, 'Europe/Moscow') AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
SELECT toInt64(0) AS x, toDateTime(1, 'Europe/Moscow') AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
||||||
SELECT toInt64(0) AS x, toUUID(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
SELECT toInt64(0) AS x, toUUID(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
||||||
SELECT toInt64(0) AS x, toDecimal32(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toInt64(0) AS x, toDecimal32(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
SELECT toInt64(0) AS x, toDecimal64(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
SELECT toInt64(0) AS x, toDecimal64(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
SELECT toInt64(0) AS x, toDecimal128(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
SELECT toInt64(0) AS x, toDecimal128(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ SELECT toUInt32(0) AS x, toFloat64(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x
|
|||||||
SELECT toUInt32(0) AS x, toDate(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toUInt32(0) AS x, toDate(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
||||||
SELECT toUInt32(0) AS x, toDateTime(1, 'Europe/Moscow') AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
SELECT toUInt32(0) AS x, toDateTime(1, 'Europe/Moscow') AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
||||||
SELECT toUInt32(0) AS x, toUUID(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
SELECT toUInt32(0) AS x, toUUID(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
||||||
SELECT toUInt32(0) AS x, toDecimal32(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toUInt32(0) AS x, toDecimal32(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
SELECT toUInt32(0) AS x, toDecimal64(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
SELECT toUInt32(0) AS x, toDecimal64(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
SELECT toUInt32(0) AS x, toDecimal128(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
SELECT toUInt32(0) AS x, toDecimal128(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
|
|
||||||
@ -134,8 +134,8 @@ SELECT toUInt64(0) AS x, toFloat64(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x
|
|||||||
SELECT toUInt64(0) AS x, toDate(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toUInt64(0) AS x, toDate(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
||||||
SELECT toUInt64(0) AS x, toDateTime(1, 'Europe/Moscow') AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
SELECT toUInt64(0) AS x, toDateTime(1, 'Europe/Moscow') AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
||||||
SELECT toUInt64(0) AS x, toUUID(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
SELECT toUInt64(0) AS x, toUUID(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 386 }
|
||||||
SELECT toUInt64(0) AS x, toDecimal32(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toUInt64(0) AS x, toDecimal32(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
SELECT toUInt64(0) AS x, toDecimal64(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toUInt64(0) AS x, toDecimal64(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
SELECT toUInt64(0) AS x, toDecimal128(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
SELECT toUInt64(0) AS x, toDecimal128(1, 0) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z);
|
||||||
|
|
||||||
SELECT toDate(0) AS x, toInt8(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
SELECT toDate(0) AS x, toInt8(1) AS y, ((x > y) ? x : y) AS z, toTypeName(x), toTypeName(y), toTypeName(z); -- { serverError 43 }
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
-1 Nullable(Int16) Nullable(Int16), Const(size = 1, Nullable(size = 1, Int16(size = 1), UInt8(size = 1)))
|
1
tests/queries/0_stateless/01423_if_nullable_cond.sql
Normal file
1
tests/queries/0_stateless/01423_if_nullable_cond.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
SELECT CAST(null, 'Nullable(UInt8)') = 1 ? CAST(null, 'Nullable(UInt8)') : -1 AS x, toTypeName(x), dumpColumnStructure(x);
|
Loading…
Reference in New Issue
Block a user