mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 11:52:27 +00:00
add Set support for ann_index_params setting
This commit is contained in:
parent
a800e0fdf9
commit
3c601e5785
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user