dbms: better [#METR-19266]

This commit is contained in:
Alexey Arno 2016-07-26 12:18:28 +03:00
parent 2514b2a04c
commit 44aa30fedf
3 changed files with 22 additions and 14 deletions

View File

@ -1,7 +1,8 @@
#pragma once
#include <DB/Columns/ColumnConst.h>
#include <DB/DataTypes/DataTypeNullable.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
@ -41,7 +42,15 @@ protected:
auto & src = res.getByPosition(i).column;
ColumnPtr converted = src->convertToFullColumnIfConst();
if (converted)
{
src = converted;
auto & type = res.getByPosition(i).type;
if (type.get()->isNull())
{
/// A ColumnNull that is converted to a full column has the type DataTypeUInt8.
type = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>());
}
}
}
return res;

View File

@ -1,6 +1,8 @@
#pragma once
#include <DB/Columns/ColumnConst.h>
#include <DB/DataTypes/DataTypeNullable.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataStreams/IBlockOutputStream.h>
#include <ext/range.hpp>
@ -42,7 +44,15 @@ private:
auto & src = block.getByPosition(i).column;
ColumnPtr converted = src->convertToFullColumnIfConst();
if (converted)
{
src = converted;
auto & type = block.getByPosition(i).type;
if (type.get()->isNull())
{
/// A ColumnNull that is converted to a full column has the type DataTypeUInt8.
type = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>());
}
}
}
return block;

View File

@ -404,19 +404,8 @@ Block Block::extractNonNullableBlock(const ColumnNumbers & arguments) const
auto nullable_col = static_cast<const ColumnNullable *>(col.column.get());
ColumnPtr nested_col = nullable_col->getNestedColumn();
DataTypePtr nested_type;
if (col.type.get()->isNull())
{
/// A ColumnNull that is converted to a full column has the type DataTypeUInt8.
nested_type = std::make_shared<DataTypeUInt8>();
}
else
{
auto nullable_type = static_cast<const DataTypeNullable *>(col.type.get());
nested_type = nullable_type->getNestedType();
}
auto nullable_type = static_cast<const DataTypeNullable *>(col.type.get());
DataTypePtr nested_type = nullable_type->getNestedType();
non_nullable_block.insert(pos, {nested_col, nested_type, col.name});
}