You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-4719 iterate into subquery looking for windowfunctions
When an outer query filter accesses an subquery column that contains an aggregate or a window function, certain optimizations can't be performed. We had been looking at the surface of the returned column. We now iterate into any functions or operations looking for aggregates and window functions.
This commit is contained in:
@ -471,22 +471,25 @@ bool SimpleColumn::sameColumn(const ReturnedColumn* rc) const
|
||||
|
||||
void SimpleColumn::setDerivedTable()
|
||||
{
|
||||
if (hasAggregate())
|
||||
if (hasAggregate() || hasWindowFunc())
|
||||
{
|
||||
fDerivedTable = "";
|
||||
return;
|
||||
}
|
||||
ReturnedColumn* rc = dynamic_cast<ReturnedColumn*>(fDerivedRefCol);
|
||||
// @todo make aggregate filter to having clause. not optimize it for now
|
||||
if (rc)
|
||||
{
|
||||
if (rc->hasAggregate() || rc->hasWindowFunc())
|
||||
{
|
||||
fDerivedTable = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// fDerivedTable is set at the parsing phase
|
||||
if (!fSchemaName.empty())
|
||||
fDerivedTable = "";
|
||||
|
||||
// @todo make aggregate filter to having clause. not optimize it for now
|
||||
if (fDerivedRefCol &&
|
||||
// TODO replace with typeid()
|
||||
(dynamic_cast<AggregateColumn*>(fDerivedRefCol) ||
|
||||
dynamic_cast<WindowFunctionColumn*>(fDerivedRefCol)))
|
||||
fDerivedTable = "";
|
||||
}
|
||||
|
||||
bool SimpleColumn::singleTable(CalpontSystemCatalog::TableAliasName& tan)
|
||||
|
@ -71,11 +71,19 @@ void getWindowFunctionCols(execplan::ParseTree* n, void* obj)
|
||||
if (afc)
|
||||
list->push_back(afc);
|
||||
else if (ac)
|
||||
list->insert(list->end(), ac->windowfunctionColumnList().begin(), ac->windowfunctionColumnList().end());
|
||||
{
|
||||
if (ac->hasWindowFunc()) // adds window functions to list
|
||||
list->insert(list->end(), ac->windowfunctionColumnList().begin(), ac->windowfunctionColumnList().end());
|
||||
}
|
||||
else if (fc)
|
||||
list->insert(list->end(), fc->windowfunctionColumnList().begin(), fc->windowfunctionColumnList().end());
|
||||
{
|
||||
if (fc->hasWindowFunc())
|
||||
list->insert(list->end(), fc->windowfunctionColumnList().begin(), fc->windowfunctionColumnList().end());
|
||||
}
|
||||
else if (sf)
|
||||
{
|
||||
list->insert(list->end(), sf->windowfunctionColumnList().begin(), sf->windowfunctionColumnList().end());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user