Merge pull request #32508 from vdimir/issue_32458

Handle const column in JoinCommon::removeColumnNullability
This commit is contained in:
alexey-milovidov 2021-12-11 01:21:10 +03:00 committed by GitHub
commit 17e5f5ccfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -225,7 +225,13 @@ void removeColumnNullability(ColumnWithTypeAndName & column)
if (column.column && column.column->isNullable())
{
column.column = column.column->convertToFullColumnIfConst();
const auto * nullable_col = checkAndGetColumn<ColumnNullable>(*column.column);
if (!nullable_col)
{
throw DB::Exception(ErrorCodes::LOGICAL_ERROR, "Column '{}' is expected to be nullable", column.dumpStructure());
}
MutableColumnPtr mutable_column = nullable_col->getNestedColumn().cloneEmpty();
insertFromNullableOrDefault(mutable_column, nullable_col);
column.column = std::move(mutable_column);

View File

@ -0,0 +1,13 @@
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1 (`id` Int32, `key` String) ENGINE = Memory;
CREATE TABLE t2 (`id` Int32, `key` String) ENGINE = Memory;
INSERT INTO t1 VALUES (0, '');
INSERT INTO t2 VALUES (0, '');
SELECT * FROM t1 ANY INNER JOIN t2 ON ((NULL = t1.key) = t2.id) AND (('' = t1.key) = t2.id);
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;