granularity

This commit is contained in:
Nikita Vasilev 2019-02-06 11:43:54 +03:00
parent e3879c0933
commit fa1e46f8a7
4 changed files with 6 additions and 5 deletions

View File

@ -3,6 +3,7 @@
#include <Core/Field.h> #include <Core/Field.h>
#include <Core/Types.h> #include <Core/Types.h>
#include <Common/FieldVisitors.h> #include <Common/FieldVisitors.h>
#include <IO/WriteHelpers.h>
#include <Parsers/ASTExpressionList.h> #include <Parsers/ASTExpressionList.h>
#include <Parsers/ASTFunction.h> #include <Parsers/ASTFunction.h>
#include <Parsers/IAST.h> #include <Parsers/IAST.h>
@ -21,7 +22,7 @@ public:
String name; String name;
IAST * expr; IAST * expr;
ASTFunction * type; ASTFunction * type;
Field granularity; UInt64 granularity;
/** Get the text that identifies this element. */ /** Get the text that identifies this element. */
String getID(char) const override { return "Index"; } String getID(char) const override { return "Index"; }
@ -52,7 +53,7 @@ public:
s.ostr << (s.hilite ? hilite_keyword : "") << " TYPE " << (s.hilite ? hilite_none : ""); s.ostr << (s.hilite ? hilite_keyword : "") << " TYPE " << (s.hilite ? hilite_none : "");
type->formatImpl(s, state, frame); type->formatImpl(s, state, frame);
s.ostr << (s.hilite ? hilite_keyword : "") << " GRANULARITY " << (s.hilite ? hilite_none : ""); s.ostr << (s.hilite ? hilite_keyword : "") << " GRANULARITY " << (s.hilite ? hilite_none : "");
s.ostr << applyVisitor(FieldVisitorToString(), granularity); s.ostr << toString(granularity);
} }
}; };

View File

@ -127,7 +127,7 @@ bool ParserIndexDeclaration::parseImpl(Pos & pos, ASTPtr & node, Expected & expe
auto index = std::make_shared<ASTIndexDeclaration>(); auto index = std::make_shared<ASTIndexDeclaration>();
index->name = typeid_cast<const ASTIdentifier &>(*name).name; index->name = typeid_cast<const ASTIdentifier &>(*name).name;
index->granularity = typeid_cast<const ASTLiteral &>(*granularity).value; index->granularity = typeid_cast<const ASTLiteral &>(*granularity).value.get<UInt64>();
index->set(index->expr, expr); index->set(index->expr, expr);
index->set(index->type, type); index->set(index->type, type);
node = index; node = index;

View File

@ -149,7 +149,7 @@ std::unique_ptr<IMergeTreeIndex> MergeTreeMinMaxIndexCreator(
} }
return std::make_unique<MergeTreeMinMaxIndex>( return std::make_unique<MergeTreeMinMaxIndex>(
node->name, std::move(minmax_expr), columns, data_types, sample, node->granularity.get<size_t>()); node->name, std::move(minmax_expr), columns, data_types, sample, node->granularity);
} }
} }

View File

@ -396,7 +396,7 @@ std::unique_ptr<IMergeTreeIndex> MergeTreeUniqueIndexCreator(
} }
return std::make_unique<MergeTreeUniqueIndex>( return std::make_unique<MergeTreeUniqueIndex>(
node->name, std::move(unique_expr), columns, data_types, header, node->granularity.get<size_t>(), max_rows); node->name, std::move(unique_expr), columns, data_types, header, node->granularity, max_rows);
} }
} }