2017-07-21 06:35:58 +00:00
|
|
|
#include <IO/Operators.h>
|
|
|
|
#include <IO/WriteBufferFromString.h>
|
2012-08-26 11:14:52 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Columns/ColumnConst.h>
|
2017-07-21 20:20:22 +00:00
|
|
|
#include <Columns/ColumnNullable.h>
|
2017-11-24 13:55:31 +00:00
|
|
|
#include <Common/FieldVisitors.h>
|
2017-07-21 20:20:22 +00:00
|
|
|
#include <Common/typeid_cast.h>
|
2011-11-06 06:22:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2013-03-06 13:56:11 +00:00
|
|
|
|
2017-07-24 01:00:31 +00:00
|
|
|
ColumnConst::ColumnConst(ColumnPtr data, size_t s)
|
|
|
|
: data(data), s(s)
|
|
|
|
{
|
|
|
|
if (data->size() != 1)
|
|
|
|
throw Exception("Incorrect size of nested column in constructor of ColumnConst: " + toString(data->size()) + ", must be 1.",
|
|
|
|
ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH);
|
|
|
|
}
|
|
|
|
|
2017-07-21 20:20:22 +00:00
|
|
|
bool ColumnConst::isNull() const
|
|
|
|
{
|
|
|
|
const ColumnNullable * column_nullable = typeid_cast<const ColumnNullable *>(data.get());
|
|
|
|
return column_nullable && column_nullable->isNullAt(0);
|
|
|
|
}
|
|
|
|
|
2017-07-24 01:00:31 +00:00
|
|
|
ColumnPtr ColumnConst::convertToFullColumn() const
|
|
|
|
{
|
|
|
|
return data->replicate(Offsets_t(1, s));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-21 20:20:22 +00:00
|
|
|
|
2017-07-21 06:35:58 +00:00
|
|
|
String ColumnConst::dump() const
|
2017-03-11 00:52:20 +00:00
|
|
|
{
|
2017-07-31 21:39:24 +00:00
|
|
|
WriteBufferFromOwnString out;
|
2017-12-07 22:11:51 +00:00
|
|
|
out << "Const, size: " << s << ", nested column: " << data->getName() << ", nested size: " << data->size();
|
2017-07-31 21:39:24 +00:00
|
|
|
if (data->size())
|
|
|
|
out << ", value: " << applyVisitor(FieldVisitorDump(), (*data)[0]);
|
2011-11-06 06:22:52 +00:00
|
|
|
|
2017-07-31 21:39:24 +00:00
|
|
|
return out.str();
|
2012-08-26 06:48:39 +00:00
|
|
|
}
|
|
|
|
|
2011-11-06 06:22:52 +00:00
|
|
|
}
|