From c4269871fe72b1e0335e36ca10f8e60a0c9c17f3 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 14 Sep 2017 23:29:54 -0500 Subject: [PATCH] MCOL-911 getAggCols needs to look into the objects --- dbcon/execplan/aggregatecolumn.cpp | 14 +++++++++ dbcon/execplan/constantfilter.cpp | 16 +++++++--- dbcon/execplan/simplefilter.cpp | 50 ++++++++++++++++++------------ 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/dbcon/execplan/aggregatecolumn.cpp b/dbcon/execplan/aggregatecolumn.cpp index 8a24e4875..b6262f998 100644 --- a/dbcon/execplan/aggregatecolumn.cpp +++ b/dbcon/execplan/aggregatecolumn.cpp @@ -55,15 +55,29 @@ void getAggCols(execplan::ParseTree* n, void* obj) SimpleFilter *sf = dynamic_cast(tn); ConstantFilter *cf = dynamic_cast(tn); if (sc) + { list->push_back(sc); + } else if (fc) + { + fc->hasAggregate(); list->insert(list->end(), fc->aggColumnList().begin(), fc->aggColumnList().end()); + } else if (ac) + { + ac->hasAggregate(); list->insert(list->end(), ac->aggColumnList().begin(), ac->aggColumnList().end()); + } else if (sf) + { + sf->hasAggregate(); list->insert(list->end(), sf->aggColumnList().begin(), sf->aggColumnList().end()); + } else if (cf) + { + cf->hasAggregate(); list->insert(list->end(), cf->aggColumnList().begin(), cf->aggColumnList().end()); + } } /** diff --git a/dbcon/execplan/constantfilter.cpp b/dbcon/execplan/constantfilter.cpp index 79e79773a..044856ad3 100644 --- a/dbcon/execplan/constantfilter.cpp +++ b/dbcon/execplan/constantfilter.cpp @@ -121,14 +121,22 @@ ostream& operator<<(ostream& output, const ConstantFilter& rhs) bool ConstantFilter::hasAggregate() { - fAggColumnList.clear(); - for (uint32_t i = 0; i < fFilterList.size(); i++) + if (fAggColumnList.empty()) { - if (fFilterList[i]->hasAggregate()) + for (uint32_t i = 0; i < fFilterList.size(); i++) { - return true; + if (fFilterList[i]->hasAggregate()) + { + fAggColumnList.insert(fAggColumnList.end(), + fFilterList[i]->aggColumnList().begin(), + fFilterList[i]->aggColumnList().end()); + } } } + if (!fAggColumnList.empty()) + { + return true; + } return false; } diff --git a/dbcon/execplan/simplefilter.cpp b/dbcon/execplan/simplefilter.cpp index ee2302015..58c041cc7 100644 --- a/dbcon/execplan/simplefilter.cpp +++ b/dbcon/execplan/simplefilter.cpp @@ -648,29 +648,41 @@ void SimpleFilter::setSimpleColumnList() bool SimpleFilter::hasAggregate() { - AggregateColumn *lac = dynamic_cast(fLhs); - AggregateColumn *rac = dynamic_cast(fRhs); - fAggColumnList.clear(); + if (fAggColumnList.empty()) + { + AggregateColumn *lac = dynamic_cast(fLhs); + AggregateColumn *rac = dynamic_cast(fRhs); + fAggColumnList.clear(); - if (lac) + if (lac) + { + fAggColumnList.insert(fAggColumnList.end(), lac); + } + if (rac) + { + fAggColumnList.insert(fAggColumnList.end(), rac); + } + + if (fLhs) + { + if (fLhs->hasAggregate()) + fAggColumnList.insert(fAggColumnList.end(), + fLhs->aggColumnList().begin(), + fLhs->aggColumnList().end()); + } + + if (fRhs) + { + if (fRhs->hasAggregate()) + fAggColumnList.insert(fAggColumnList.end(), + fRhs->aggColumnList().begin(), + fRhs->aggColumnList().end()); + } + } + if (!fAggColumnList.empty()) { return true; } - else if (fLhs) - { - if (fLhs->hasAggregate()) - return true; - } - - if (rac) - { - return true; - } - else if (fRhs) - { - if (fRhs->hasAggregate()) - return true; - } return false; }