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)
|
||||
{
|
||||
stream << "IDataType(name = " << what.getName() << ", default = " << what.getDefault();
|
||||
stream << "IDataType(name = " << what.getName() << ", default = " << what.getDefault() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -67,17 +67,34 @@ std::ostream & operator<<(std::ostream & stream, const DB::Block & what)
|
||||
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)
|
||||
{
|
||||
stream << "ColumnWithTypeAndName(name = " << what.name << ", type = " << what.type << ", column = " << what.column << ")";
|
||||
return stream;
|
||||
stream << "ColumnWithTypeAndName(name = " << what.name << ", type = " << what.type << ", column = ";
|
||||
return printCOWPtr<DB::IColumn>(stream, what.column) << ")";
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & stream, const DB::IColumn & what)
|
||||
{
|
||||
stream << "IColumn(name = " << what.getName()
|
||||
// TODO: maybe many flags here
|
||||
<< ")";
|
||||
stream << "IColumn(" << what.dumpStructure() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
@ -116,7 +133,7 @@ std::ostream & operator<<(std::ostream & stream, const DB::IAST & what)
|
||||
std::ostream & operator<<(std::ostream & stream, const DB::ExpressionAnalyzer & what)
|
||||
{
|
||||
stream << "ExpressionAnalyzer{"
|
||||
<< "hasAggregation="<<what.hasAggregation()
|
||||
<< "hasAggregation=" << what.hasAggregation()
|
||||
<< ", RequiredColumns=" << what.getRequiredColumns()
|
||||
<< ", SubqueriesForSet=" << what.getSubqueriesForSets()
|
||||
<< ", ExternalTables=" << what.getExternalTables()
|
||||
|
@ -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.
|
||||
ColumnWithTypeAndName & col = sample_block.safeGetByPosition(result_position);
|
||||
if (!col.column->isColumnConst())
|
||||
{
|
||||
col.column = nullptr;
|
||||
}
|
||||
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});
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ std::ostream & operator<<(std::ostream & stream, const std::chrono::time_point<c
|
||||
template <typename T>
|
||||
std::ostream & operator<<(std::ostream & stream, const std::shared_ptr<T> & what)
|
||||
{
|
||||
stream << "shared_ptr("<< what.get() <<", use_count = " << what.use_count() << ") {";
|
||||
stream << "shared_ptr(" << what.get() <<", use_count = " << what.use_count() << ") {";
|
||||
if (what)
|
||||
stream << *what;
|
||||
else
|
||||
@ -156,7 +156,7 @@ std::ostream & operator<<(std::ostream & stream, const std::shared_ptr<T> & what
|
||||
template <typename T>
|
||||
std::ostream & operator<<(std::ostream & stream, const std::unique_ptr<T> & what)
|
||||
{
|
||||
stream << "unique_ptr("<< what.get() <<") {";
|
||||
stream << "unique_ptr(" << what.get() <<") {";
|
||||
if (what)
|
||||
stream << *what;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user