mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #55353 from ClickHouse/fix-garbage-2
Fix trash optimization (up to a certain extent)
This commit is contained in:
commit
b619d07baf
@ -204,26 +204,41 @@ inline ASTs & getFunctionOperands(const ASTFunction * or_function)
|
||||
|
||||
bool LogicalExpressionsOptimizer::isLowCardinalityEqualityChain(const std::vector<ASTFunction *> & functions) const
|
||||
{
|
||||
if (functions.size() > 1)
|
||||
if (functions.size() <= 1)
|
||||
return false;
|
||||
|
||||
if (!functions[0])
|
||||
return false;
|
||||
|
||||
/// Check if the identifier has LowCardinality type.
|
||||
auto & first_operands = getFunctionOperands(functions.at(0));
|
||||
|
||||
if (first_operands.empty())
|
||||
return false;
|
||||
|
||||
if (!first_operands[0])
|
||||
return false;
|
||||
|
||||
const auto * identifier = first_operands.at(0)->as<ASTIdentifier>();
|
||||
if (!identifier)
|
||||
return false;
|
||||
|
||||
auto pos = IdentifierSemantic::getMembership(*identifier);
|
||||
if (!pos)
|
||||
pos = IdentifierSemantic::chooseTableColumnMatch(*identifier, tables_with_columns, true);
|
||||
|
||||
if (!pos)
|
||||
return false;
|
||||
|
||||
if (*pos >= tables_with_columns.size())
|
||||
return false;
|
||||
|
||||
if (auto data_type_and_name = tables_with_columns.at(*pos).columns.tryGetByName(identifier->shortName()))
|
||||
{
|
||||
/// Check if identifier is LowCardinality type
|
||||
auto & first_operands = getFunctionOperands(functions[0]);
|
||||
const auto * identifier = first_operands[0]->as<ASTIdentifier>();
|
||||
if (identifier)
|
||||
{
|
||||
auto pos = IdentifierSemantic::getMembership(*identifier);
|
||||
if (!pos)
|
||||
pos = IdentifierSemantic::chooseTableColumnMatch(*identifier, tables_with_columns, true);
|
||||
if (pos)
|
||||
{
|
||||
if (auto data_type_and_name = tables_with_columns[*pos].columns.tryGetByName(identifier->shortName()))
|
||||
{
|
||||
if (typeid_cast<const DataTypeLowCardinality *>(data_type_and_name->type.get()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeid_cast<const DataTypeLowCardinality *>(data_type_and_name->type.get()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
0
|
3
tests/queries/0_stateless/02893_trash_optimization.sql
Normal file
3
tests/queries/0_stateless/02893_trash_optimization.sql
Normal file
@ -0,0 +1,3 @@
|
||||
SELECT *
|
||||
FROM merge('system', '^one$') AS one
|
||||
WHERE (one.dummy = 0) OR (one.dummy = 1);
|
Loading…
Reference in New Issue
Block a user