add Set support for ann_index_params setting

This commit is contained in:
Hakob Saghatelyan 2022-05-11 21:13:43 +00:00 committed by Vladimir Makarov
parent a800e0fdf9
commit 3c601e5785
2 changed files with 5 additions and 26 deletions

View File

@ -5,6 +5,8 @@
#include <Parsers/ASTSelectQuery.h>
#include <Parsers/ASTSetQuery.h>
#include <Interpreters/Context.h>
#include <Storages/MergeTree/CommonANNIndexes.h>
namespace DB
@ -29,6 +31,8 @@ ANNCondition::ANNCondition(const SelectQueryInfo & query_info,
buildRPN(query_info);
// Match rpns with supported types
index_is_useful = matchAllRPNS();
// Get from settings ANNIndex parameters
ann_index_params = context->getSettings().get("ann_index_params").get<String>();
}
bool ANNCondition::alwaysUnknownOrTrue(String metric_name) const
@ -114,11 +118,6 @@ void ANNCondition::buildRPN(const SelectQueryInfo & query)
traverseAST(select.limitLength(), rpn_limit_clause);
}
if (select.settings()) // If query has SETTINGS section
{
parseSettings(select.settings());
}
if (select.orderBy()) // If query has ORDERBY section
{
traverseOrderByAST(select.orderBy(), rpn_order_by_clause);
@ -310,21 +309,6 @@ bool ANNCondition::matchRPNLimit(RPN & rpn, LimitExpression & expr)
return false;
}
void ANNCondition::parseSettings(const ASTPtr & node)
{
if (const auto * set = node->as<ASTSetQuery>())
{
for (const auto & change : set->changes)
{
if (change.name == "ann_index_params")
{
ann_index_params = change.value.get<String>();
return;
}
}
}
}
bool ANNCondition::matchRPNOrderBy(RPN & rpn, ANNExpression & expr)
{
// ORDERBY section must have at least 3 expressions

View File

@ -165,7 +165,6 @@ private:
// Traverses the AST of ORDERBY section
void traverseOrderByAST(const ASTPtr & node, RPN & rpn);
// Checks that at least one rpn is matching for index
// New RPNs for other query types can be added here
bool matchAllRPNS();
@ -179,10 +178,6 @@ private:
// Returns true and stores Length if we have valid LIMIT clause in query
static bool matchRPNLimit(RPN & rpn, LimitExpression & expr);
// Parses SETTINGS section, stores the new value for 'ann_index_params'
void parseSettings(const ASTPtr & node);
/* Matches dist function, target vector, column name */
static bool matchMainParts(RPN::iterator & iter, RPN::iterator & end, ANNExpression & expr, bool & identifier_found);