2015-06-29 05:46:55 +00:00
|
|
|
#include <DB/Common/SipHash.h>
|
2015-10-12 07:05:54 +00:00
|
|
|
#include <DB/Core/FieldVisitors.h>
|
2015-06-29 05:46:55 +00:00
|
|
|
#include <DB/Parsers/ASTLiteral.h>
|
2017-01-06 17:41:19 +00:00
|
|
|
#include <DB/IO/WriteHelpers.h>
|
2015-06-29 05:46:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
String ASTLiteral::getColumnName() const
|
|
|
|
{
|
2017-01-06 17:41:19 +00:00
|
|
|
/// Special case for very large arrays. Instead of listing all elements, will use hash of them.
|
|
|
|
/// (Otherwise column name will be too long, that will lead to significant slowdown of expression analysis.)
|
2015-06-29 05:48:08 +00:00
|
|
|
if (value.getType() == Field::Types::Array
|
2017-01-06 17:41:19 +00:00
|
|
|
&& value.get<const Array &>().size() > 100) /// 100 - just arbitary value.
|
2015-06-29 05:46:55 +00:00
|
|
|
{
|
|
|
|
SipHash hash;
|
2017-01-06 17:41:19 +00:00
|
|
|
applyVisitor(FieldVisitorHash(hash), value);
|
2015-06-29 05:46:55 +00:00
|
|
|
UInt64 low, high;
|
|
|
|
hash.get128(low, high);
|
|
|
|
return "__array_" + toString(low) + "_" + toString(high);
|
2015-06-29 05:48:08 +00:00
|
|
|
}
|
2015-06-29 05:46:55 +00:00
|
|
|
|
2017-01-06 17:41:19 +00:00
|
|
|
return applyVisitor(FieldVisitorToString(), value);
|
2015-06-29 05:46:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|