mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Better semantic of sharing columns: development [#CLICKHOUSE-2].
This commit is contained in:
parent
75c0ad10ab
commit
6f7d2b99ea
@ -33,7 +33,7 @@ std::ostream & operator<<(std::ostream & stream, const DB::NameAndTypePair & wha
|
|||||||
|
|
||||||
std::ostream & operator<<(std::ostream & stream, const DB::IDataType & what)
|
std::ostream & operator<<(std::ostream & stream, const DB::IDataType & what)
|
||||||
{
|
{
|
||||||
stream << "IDataType(name = " << what.getName() << ", default = " << what.getDefault();
|
stream << "IDataType(name = " << what.getName() << ", default = " << what.getDefault() << ")";
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,17 +67,34 @@ std::ostream & operator<<(std::ostream & stream, const DB::Block & what)
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include <Common/COWPtr.h>
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::ostream & printCOWPtr(std::ostream & stream, const typename COWPtr<T>::Ptr & what)
|
||||||
|
{
|
||||||
|
stream << "COWPtr::Ptr(" << what.get();
|
||||||
|
if (what)
|
||||||
|
stream << ", use_count = " << what->use_count();
|
||||||
|
stream << ") {";
|
||||||
|
if (what)
|
||||||
|
stream << *what;
|
||||||
|
else
|
||||||
|
stream << "nullptr";
|
||||||
|
stream << "}";
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & stream, const DB::ColumnWithTypeAndName & what)
|
std::ostream & operator<<(std::ostream & stream, const DB::ColumnWithTypeAndName & what)
|
||||||
{
|
{
|
||||||
stream << "ColumnWithTypeAndName(name = " << what.name << ", type = " << what.type << ", column = " << what.column << ")";
|
stream << "ColumnWithTypeAndName(name = " << what.name << ", type = " << what.type << ", column = ";
|
||||||
return stream;
|
return printCOWPtr<DB::IColumn>(stream, what.column) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & stream, const DB::IColumn & what)
|
std::ostream & operator<<(std::ostream & stream, const DB::IColumn & what)
|
||||||
{
|
{
|
||||||
stream << "IColumn(name = " << what.getName()
|
stream << "IColumn(" << what.dumpStructure() << ")";
|
||||||
// TODO: maybe many flags here
|
|
||||||
<< ")";
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,9 +227,20 @@ void ExpressionAction::prepare(Block & sample_block)
|
|||||||
/// If the result is not a constant, just in case, we will consider the result as unknown.
|
/// If the result is not a constant, just in case, we will consider the result as unknown.
|
||||||
ColumnWithTypeAndName & col = sample_block.safeGetByPosition(result_position);
|
ColumnWithTypeAndName & col = sample_block.safeGetByPosition(result_position);
|
||||||
if (!col.column->isColumnConst())
|
if (!col.column->isColumnConst())
|
||||||
|
{
|
||||||
col.column = nullptr;
|
col.column = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/// All constant (literal) columns in block are added with size 1.
|
||||||
|
/// But if there was no columns in block before executing a function, the result has size 0.
|
||||||
|
/// Change the size to 1.
|
||||||
|
|
||||||
|
if (col.column->empty())
|
||||||
|
col.column = col.column->cloneResized(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
sample_block.insert({nullptr, result_type, result_name});
|
sample_block.insert({nullptr, result_type, result_name});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user