mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #58875 from ClickHouse/fix-indexhint-rpn-builder
Fix RPN construction for indexHint
This commit is contained in:
commit
a5e0be484a
@ -14,7 +14,9 @@
|
||||
#include <Columns/ColumnConst.h>
|
||||
#include <Columns/ColumnSet.h>
|
||||
|
||||
#include <Functions/indexHint.h>
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Functions/IFunctionAdaptors.h>
|
||||
|
||||
#include <Storages/KeyDescription.h>
|
||||
|
||||
@ -390,6 +392,15 @@ size_t RPNBuilderFunctionTreeNode::getArgumentsSize() const
|
||||
}
|
||||
else
|
||||
{
|
||||
// indexHint arguments are stored inside of `FunctionIndexHint` class,
|
||||
// because they are used only for index analysis.
|
||||
if (dag_node->function_base->getName() == "indexHint")
|
||||
{
|
||||
const auto * adaptor = typeid_cast<const FunctionToFunctionBaseAdaptor *>(dag_node->function_base.get());
|
||||
const auto * index_hint = typeid_cast<const FunctionIndexHint *>(adaptor->getFunction().get());
|
||||
return index_hint->getActions()->getOutputs().size();
|
||||
}
|
||||
|
||||
return dag_node->children.size();
|
||||
}
|
||||
}
|
||||
@ -409,6 +420,15 @@ RPNBuilderTreeNode RPNBuilderFunctionTreeNode::getArgumentAt(size_t index) const
|
||||
}
|
||||
else
|
||||
{
|
||||
// indexHint arguments are stored inside of `FunctionIndexHint` class,
|
||||
// because they are used only for index analysis.
|
||||
if (dag_node->function_base->getName() == "indexHint")
|
||||
{
|
||||
const auto * adaptor = typeid_cast<const FunctionToFunctionBaseAdaptor *>(dag_node->function_base.get());
|
||||
const auto * index_hint = typeid_cast<const FunctionIndexHint *>(adaptor->getFunction().get());
|
||||
return RPNBuilderTreeNode(index_hint->getActions()->getOutputs()[index], tree_context);
|
||||
}
|
||||
|
||||
return RPNBuilderTreeNode(dag_node->children[index], tree_context);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
CREATE TABLE tab
|
||||
(
|
||||
`foo` Array(LowCardinality(String)),
|
||||
INDEX idx foo TYPE bloom_filter GRANULARITY 1
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PRIMARY KEY tuple();
|
||||
|
||||
INSERT INTO tab SELECT if(number % 2, ['value'], [])
|
||||
FROM system.numbers
|
||||
LIMIT 10000;
|
||||
|
||||
SELECT *
|
||||
FROM tab
|
||||
PREWHERE indexHint(indexHint(-1, 0.))
|
||||
WHERE has(foo, 'b');
|
||||
|
||||
SELECT *
|
||||
FROM tab
|
||||
PREWHERE indexHint(0);
|
Loading…
Reference in New Issue
Block a user