You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-10-31 18:30:33 +03:00
Revert "fix(joblist,QA): introduced extended SC ptrs collector to resolve the issue when ParseTree consist of ArithmCol-AggCol does not return SCs from AggCol."
This reverts commit 8c0c85080c.
This commit is contained in:
@@ -83,18 +83,6 @@ void getAggCols(execplan::ParseTree* n, void* obj)
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<SimpleColumn*>& getSCsFromRCForExtended(const SRCP& srcp)
|
||||
{
|
||||
srcp->setSimpleColumnListExtended();
|
||||
return srcp->simpleColumnListExtended();
|
||||
}
|
||||
|
||||
const std::vector<SimpleColumn*>& getSCsFromRC(const SRCP& srcp)
|
||||
{
|
||||
srcp->setSimpleColumnList();
|
||||
return srcp->simpleColumnList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
@@ -141,36 +129,18 @@ AggregateColumn::AggregateColumn(const AggregateColumn& rhs, const uint32_t sess
|
||||
void AggregateColumn::setSimpleColumnList()
|
||||
{
|
||||
fSimpleColumnList.clear();
|
||||
return setSimpleColumnList_(false);
|
||||
}
|
||||
|
||||
void AggregateColumn::setSimpleColumnListExtended()
|
||||
{
|
||||
fSimpleColumnListExtended.clear();
|
||||
return setSimpleColumnList_(true);
|
||||
}
|
||||
|
||||
void AggregateColumn::setSimpleColumnList_(const bool extractSCsfromAggCol)
|
||||
{
|
||||
for (const auto& parm : aggParms())
|
||||
{
|
||||
if (!parm)
|
||||
continue;
|
||||
|
||||
auto aggParmsAsSCVec = (extractSCsfromAggCol) ? getSCsFromRCForExtended(parm) : getSCsFromRC(parm);
|
||||
|
||||
for (auto* sc : aggParmsAsSCVec)
|
||||
|
||||
parm->setSimpleColumnList();
|
||||
for (auto* sc : parm->simpleColumnList())
|
||||
{
|
||||
if (sc)
|
||||
{
|
||||
if (extractSCsfromAggCol)
|
||||
{
|
||||
fSimpleColumnListExtended.push_back(sc);
|
||||
}
|
||||
else
|
||||
{
|
||||
fSimpleColumnList.push_back(sc);
|
||||
}
|
||||
fSimpleColumnList.push_back(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,9 +161,7 @@ class AggregateColumn : public ReturnedColumn
|
||||
fAggParms = parms;
|
||||
}
|
||||
|
||||
void setSimpleColumnList_(const bool extractSCsfromAggCol);
|
||||
void setSimpleColumnList() override;
|
||||
void setSimpleColumnListExtended() override;
|
||||
|
||||
/** return a copy of this pointer
|
||||
*
|
||||
|
||||
@@ -447,12 +447,6 @@ void ArithmeticColumn::setSimpleColumnList()
|
||||
fExpression->walk(getSimpleCols, &fSimpleColumnList);
|
||||
}
|
||||
|
||||
void ArithmeticColumn::setSimpleColumnListExtended()
|
||||
{
|
||||
fSimpleColumnListExtended.clear();
|
||||
fExpression->walk(getSimpleColsExtended, &fSimpleColumnListExtended);
|
||||
}
|
||||
|
||||
std::optional<CalpontSystemCatalog::TableAliasName> ArithmeticColumn::singleTable()
|
||||
{
|
||||
setSimpleColumnList();
|
||||
|
||||
@@ -169,10 +169,12 @@ class ArithmeticColumn : public ReturnedColumn
|
||||
|
||||
void setDerivedTable() override;
|
||||
void replaceRealCol(std::vector<SRCP>&) override;
|
||||
const std::vector<SimpleColumn*>& simpleColumnList() const override
|
||||
{
|
||||
return fSimpleColumnList;
|
||||
}
|
||||
void setSimpleColumnList() override;
|
||||
|
||||
void setSimpleColumnListExtended() override;
|
||||
|
||||
/**
|
||||
* Return the table that the column arguments belong to.
|
||||
*
|
||||
|
||||
@@ -331,22 +331,4 @@ void ConstantFilter::setSimpleColumnList()
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<SimpleColumn*>& ConstantFilter::simpleColumnListExtended()
|
||||
{
|
||||
return fSimpleColumnListExtended;
|
||||
}
|
||||
|
||||
void ConstantFilter::setSimpleColumnListExtended()
|
||||
{
|
||||
fSimpleColumnListExtended.clear();
|
||||
|
||||
for (uint32_t i = 0; i < fFilterList.size(); i++)
|
||||
{
|
||||
fFilterList[i]->setSimpleColumnListExtended();
|
||||
fSimpleColumnListExtended.insert(fSimpleColumnListExtended.end(),
|
||||
fFilterList[i]->simpleColumnListExtended().begin(),
|
||||
fFilterList[i]->simpleColumnListExtended().end());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace execplan
|
||||
|
||||
@@ -202,10 +202,8 @@ class ConstantFilter : public Filter
|
||||
|
||||
// get all simple columns involved in this column
|
||||
const std::vector<SimpleColumn*>& simpleColumnList();
|
||||
const std::vector<SimpleColumn*>& simpleColumnListExtended();
|
||||
// walk through the constant filter operands to re-populate fSimpleColumnList
|
||||
void setSimpleColumnList();
|
||||
void setSimpleColumnListExtended();
|
||||
|
||||
// get all aggregate columns involved in this column
|
||||
const std::vector<AggregateColumn*>& aggColumnList() const
|
||||
@@ -215,7 +213,6 @@ class ConstantFilter : public Filter
|
||||
|
||||
private:
|
||||
std::vector<SimpleColumn*> fSimpleColumnList;
|
||||
std::vector<SimpleColumn*> fSimpleColumnListExtended{};
|
||||
std::vector<AggregateColumn*> fAggColumnList;
|
||||
std::vector<WindowFunctionColumn*> fWindowFunctionColumnList;
|
||||
};
|
||||
|
||||
@@ -46,6 +46,7 @@ using namespace boost;
|
||||
#include "functor_str.h"
|
||||
using namespace funcexp;
|
||||
|
||||
|
||||
namespace execplan
|
||||
{
|
||||
/**
|
||||
@@ -140,8 +141,7 @@ string FunctionColumn::toCppCode(IncludeSet& includes) const
|
||||
|
||||
auto fFuncParmsInString = fData.substr(fFunctionName.size() + 1, fData.size() - fFunctionName.size() - 2);
|
||||
|
||||
ss << "FunctionColumn(" << std::quoted(fFunctionName) << ", " << std::quoted(fFuncParmsInString) << ", "
|
||||
<< sessionID() << ")";
|
||||
ss << "FunctionColumn(" << std::quoted(fFunctionName) << ", " << std::quoted(fFuncParmsInString) << ", " << sessionID() << ")";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
@@ -521,14 +521,6 @@ void FunctionColumn::setSimpleColumnList()
|
||||
fFunctionParms[i]->walk(getSimpleCols, &fSimpleColumnList);
|
||||
}
|
||||
|
||||
void FunctionColumn::setSimpleColumnListExtended()
|
||||
{
|
||||
fSimpleColumnListExtended.clear();
|
||||
|
||||
for (uint i = 0; i < fFunctionParms.size(); i++)
|
||||
fFunctionParms[i]->walk(getSimpleColsExtended, &fSimpleColumnListExtended);
|
||||
}
|
||||
|
||||
std::optional<CalpontSystemCatalog::TableAliasName> FunctionColumn::singleTable()
|
||||
{
|
||||
setSimpleColumnList();
|
||||
|
||||
@@ -159,9 +159,12 @@ class FunctionColumn : public ReturnedColumn
|
||||
bool hasWindowFunc() override;
|
||||
void setDerivedTable() override;
|
||||
void replaceRealCol(std::vector<SRCP>&) override;
|
||||
virtual const std::vector<SimpleColumn*>& simpleColumnList() const override
|
||||
{
|
||||
return fSimpleColumnList;
|
||||
}
|
||||
|
||||
void setSimpleColumnList() override;
|
||||
void setSimpleColumnListExtended() override;
|
||||
/**
|
||||
* Return the tableAlias name of the table that the column arguments belong to.
|
||||
*
|
||||
|
||||
@@ -260,9 +260,4 @@ void ReturnedColumn::setSimpleColumnList()
|
||||
fSimpleColumnList.clear();
|
||||
}
|
||||
|
||||
void ReturnedColumn::setSimpleColumnListExtended()
|
||||
{
|
||||
fSimpleColumnListExtended.clear();
|
||||
}
|
||||
|
||||
} // namespace execplan
|
||||
|
||||
@@ -287,11 +287,6 @@ class ReturnedColumn : public TreeNode
|
||||
return fSimpleColumnList;
|
||||
}
|
||||
|
||||
virtual const std::vector<SimpleColumn*>& simpleColumnListExtended() const
|
||||
{
|
||||
return fSimpleColumnListExtended;
|
||||
}
|
||||
|
||||
/* @brief traverse this ReturnedColumn and re-populate fSimpleColumnList.
|
||||
*
|
||||
* @note all ReturnedColumns that may have simple column arguments added
|
||||
@@ -299,8 +294,6 @@ class ReturnedColumn : public TreeNode
|
||||
*/
|
||||
virtual void setSimpleColumnList();
|
||||
|
||||
virtual void setSimpleColumnListExtended();
|
||||
|
||||
// get all aggregate column list in this expression
|
||||
const std::vector<AggregateColumn*>& aggColumnList() const
|
||||
{
|
||||
@@ -349,10 +342,7 @@ class ReturnedColumn : public TreeNode
|
||||
uint64_t fOrderPos; /// for order by and group by column
|
||||
uint64_t fColSource; /// from which subquery
|
||||
int64_t fColPosition; /// the column position in the source subquery
|
||||
// The difference b/w the two vectors is that the second one is used to store SCs
|
||||
// are are used by AggegateColumn.
|
||||
std::vector<SimpleColumn*> fSimpleColumnList;
|
||||
std::vector<SimpleColumn*> fSimpleColumnListExtended{};
|
||||
std::vector<AggregateColumn*> fAggColumnList;
|
||||
std::vector<WindowFunctionColumn*> fWindowFunctionColumnList;
|
||||
bool fHasAggregate; /// connector internal use. no need to serialize
|
||||
|
||||
@@ -91,48 +91,6 @@ void getSimpleCols(execplan::ParseTree* n, void* obj)
|
||||
}
|
||||
}
|
||||
|
||||
void getSimpleColsExtended(execplan::ParseTree* n, void* obj)
|
||||
{
|
||||
vector<SimpleColumn*>* list = reinterpret_cast<vector<SimpleColumn*>*>(obj);
|
||||
TreeNode* tn = n->data();
|
||||
SimpleColumn* sc = dynamic_cast<SimpleColumn*>(tn);
|
||||
FunctionColumn* fc = dynamic_cast<FunctionColumn*>(tn);
|
||||
ArithmeticColumn* ac = dynamic_cast<ArithmeticColumn*>(tn);
|
||||
SimpleFilter* sf = dynamic_cast<SimpleFilter*>(tn);
|
||||
ConstantFilter* cf = dynamic_cast<ConstantFilter*>(tn);
|
||||
AggregateColumn* agc = dynamic_cast<AggregateColumn*>(tn);
|
||||
|
||||
if (sc)
|
||||
{
|
||||
list->push_back(sc);
|
||||
}
|
||||
else if (fc)
|
||||
{
|
||||
fc->setSimpleColumnListExtended();
|
||||
list->insert(list->end(), fc->simpleColumnListExtended().begin(), fc->simpleColumnListExtended().end());
|
||||
}
|
||||
else if (ac)
|
||||
{
|
||||
ac->setSimpleColumnListExtended();
|
||||
list->insert(list->end(), ac->simpleColumnListExtended().begin(), ac->simpleColumnListExtended().end());
|
||||
}
|
||||
else if (agc)
|
||||
{
|
||||
agc->setSimpleColumnListExtended();
|
||||
list->insert(list->end(), agc->simpleColumnListExtended().begin(), agc->simpleColumnListExtended().end());
|
||||
}
|
||||
else if (sf)
|
||||
{
|
||||
sf->setSimpleColumnListExtended();
|
||||
list->insert(list->end(), sf->simpleColumnListExtended().begin(), sf->simpleColumnListExtended().end());
|
||||
}
|
||||
else if (cf)
|
||||
{
|
||||
cf->setSimpleColumnListExtended();
|
||||
list->insert(list->end(), cf->simpleColumnListExtended().begin(), cf->simpleColumnListExtended().end());
|
||||
}
|
||||
}
|
||||
|
||||
ParseTree* replaceRefCol(ParseTree*& n, CalpontSelectExecutionPlan::ReturnedColumnList& derivedColList)
|
||||
{
|
||||
ParseTree* lhs = n->left();
|
||||
@@ -824,18 +782,6 @@ void SimpleColumn::setSimpleColumnList()
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleColumn::setSimpleColumnListExtended()
|
||||
{
|
||||
if (fSimpleColumnListExtended.empty())
|
||||
{
|
||||
fSimpleColumnListExtended.push_back(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
fSimpleColumnListExtended.back() = this;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(
|
||||
std::vector<SimpleColumn*> simpleColumnList)
|
||||
{
|
||||
|
||||
@@ -266,7 +266,7 @@ class SimpleColumn : public ReturnedColumn
|
||||
std::optional<CalpontSystemCatalog::TableAliasName> singleTable() override;
|
||||
|
||||
void setSimpleColumnList() override;
|
||||
void setSimpleColumnListExtended() override;
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -407,10 +407,8 @@ std::ostream& operator<<(std::ostream& output, const SimpleColumn& rhs);
|
||||
* utility function to extract all simple columns from a parse tree
|
||||
*/
|
||||
void getSimpleCols(ParseTree* n, void* obj);
|
||||
void getSimpleColsExtended(execplan::ParseTree* n, void* obj);
|
||||
ParseTree* replaceRefCol(ParseTree*& n, CalpontSelectExecutionPlan::ReturnedColumnList&);
|
||||
|
||||
std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(
|
||||
std::vector<SimpleColumn*> simpleColumnList);
|
||||
std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(std::vector<SimpleColumn*> simpleColumnList);
|
||||
|
||||
} // namespace execplan
|
||||
|
||||
@@ -810,11 +810,6 @@ const std::vector<SimpleColumn*>& SimpleFilter::simpleColumnList()
|
||||
return fSimpleColumnList;
|
||||
}
|
||||
|
||||
const std::vector<SimpleColumn*>& SimpleFilter::simpleColumnListExtended()
|
||||
{
|
||||
return fSimpleColumnListExtended;
|
||||
}
|
||||
|
||||
void SimpleFilter::setSimpleColumnList()
|
||||
{
|
||||
SimpleColumn* lsc = dynamic_cast<SimpleColumn*>(fLhs);
|
||||
@@ -844,35 +839,6 @@ void SimpleFilter::setSimpleColumnList()
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleFilter::setSimpleColumnListExtended()
|
||||
{
|
||||
SimpleColumn* lsc = dynamic_cast<SimpleColumn*>(fLhs);
|
||||
SimpleColumn* rsc = dynamic_cast<SimpleColumn*>(fRhs);
|
||||
fSimpleColumnListExtended.clear();
|
||||
|
||||
if (lsc)
|
||||
{
|
||||
fSimpleColumnListExtended.push_back(lsc);
|
||||
}
|
||||
else if (fLhs)
|
||||
{
|
||||
fLhs->setSimpleColumnListExtended();
|
||||
fSimpleColumnList.insert(fSimpleColumnList.end(), fLhs->simpleColumnListExtended().begin(),
|
||||
fLhs->simpleColumnListExtended().end());
|
||||
}
|
||||
|
||||
if (rsc)
|
||||
{
|
||||
fSimpleColumnList.push_back(rsc);
|
||||
}
|
||||
else if (fRhs)
|
||||
{
|
||||
fRhs->setSimpleColumnListExtended();
|
||||
fSimpleColumnList.insert(fSimpleColumnList.end(), fRhs->simpleColumnListExtended().begin(),
|
||||
fRhs->simpleColumnListExtended().end());
|
||||
}
|
||||
}
|
||||
|
||||
bool SimpleFilter::hasAggregate()
|
||||
{
|
||||
if (fAggColumnList.empty())
|
||||
|
||||
@@ -246,10 +246,8 @@ class SimpleFilter : public Filter
|
||||
|
||||
// get all simple columns involved in this column
|
||||
const std::vector<SimpleColumn*>& simpleColumnList();
|
||||
const std::vector<SimpleColumn*>& simpleColumnListExtended();
|
||||
// walk through the simple filter operands to re-populate fSimpleColumnList
|
||||
void setSimpleColumnList();
|
||||
void setSimpleColumnListExtended();
|
||||
// walk through the simple filter operands to check existence of aggregate
|
||||
bool hasAggregate();
|
||||
|
||||
@@ -267,7 +265,6 @@ class SimpleFilter : public Filter
|
||||
|
||||
private:
|
||||
std::vector<SimpleColumn*> fSimpleColumnList;
|
||||
std::vector<SimpleColumn*> fSimpleColumnListExtended{};
|
||||
std::vector<AggregateColumn*> fAggColumnList;
|
||||
std::vector<WindowFunctionColumn*> fWindowFunctionColumnList;
|
||||
};
|
||||
|
||||
@@ -67,6 +67,8 @@ uint32_t uniqTupleKey(JobInfo& jobInfo, CalpontSystemCatalog::OID& o, CalpontSys
|
||||
return iter->second;
|
||||
|
||||
uint32_t newId = jobInfo.keyInfo->nextKey++;
|
||||
// cout << "new id: " << newId << " -- " << o << ", " << pi << ", " << nm << ", " << vw << ", " << sn << ",
|
||||
// " << subId << endl;
|
||||
jobInfo.keyInfo->tupleKeyMap[id] = newId;
|
||||
jobInfo.keyInfo->tupleKeyVec.push_back(id);
|
||||
jobInfo.keyInfo->tupleKeyToTableOid.insert(make_pair(newId, t));
|
||||
|
||||
@@ -523,15 +523,27 @@ void tryToUpdateScToUseRewrittenDerived(
|
||||
}
|
||||
|
||||
void updateSCsUsingIteration(optimizer::TableAliasToNewAliasAndSCPositionsMap& tableAliasToSCPositionsMap,
|
||||
std::vector<execplan::SRCP>& rcs)
|
||||
std::vector<execplan::SRCP>& rcs, const bool ignoreAgg)
|
||||
{
|
||||
for (auto& rc : rcs)
|
||||
{
|
||||
rc->setSimpleColumnListExtended();
|
||||
for (auto* sc : rc->simpleColumnListExtended())
|
||||
rc->setSimpleColumnList();
|
||||
for (auto* sc : rc->simpleColumnList())
|
||||
{
|
||||
tryToUpdateScToUseRewrittenDerived(sc, tableAliasToSCPositionsMap);
|
||||
}
|
||||
|
||||
if (!ignoreAgg && rc->hasAggregate())
|
||||
{
|
||||
for (auto* agc : rc->aggColumnList())
|
||||
{
|
||||
agc->setSimpleColumnList();
|
||||
for (auto* sc : agc->simpleColumnList())
|
||||
{
|
||||
tryToUpdateScToUseRewrittenDerived(sc, tableAliasToSCPositionsMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +551,7 @@ void updateSCsUsingWalkers(optimizer::TableAliasToNewAliasAndSCPositionsMap& tab
|
||||
execplan::ParseTree* pt)
|
||||
{
|
||||
std::vector<execplan::SimpleColumn*> simpleColumns;
|
||||
pt->walk(execplan::getSimpleColsExtended, &simpleColumns);
|
||||
pt->walk(execplan::getSimpleCols, &simpleColumns);
|
||||
for (auto* sc : simpleColumns)
|
||||
{
|
||||
tryToUpdateScToUseRewrittenDerived(sc, tableAliasToSCPositionsMap);
|
||||
@@ -610,7 +622,7 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
{
|
||||
for (auto& rc : csep.returnedCols())
|
||||
{
|
||||
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.returnedCols());
|
||||
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.returnedCols(), false);
|
||||
newReturnedColumns.push_back(rc);
|
||||
}
|
||||
|
||||
@@ -621,13 +633,13 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
// 3d pass over GROUP BY columns
|
||||
if (!csep.groupByCols().empty())
|
||||
{
|
||||
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.groupByCols());
|
||||
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.groupByCols(), true);
|
||||
}
|
||||
|
||||
// 4th pass over ORDER BY columns
|
||||
if (!csep.orderByCols().empty())
|
||||
{
|
||||
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.orderByCols());
|
||||
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.orderByCols(), false);
|
||||
}
|
||||
|
||||
// 5th pass over filters to use derived table SCs in filters
|
||||
@@ -664,7 +676,7 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
if (auto subFilters = sub->filters())
|
||||
{
|
||||
std::vector<execplan::SimpleColumn*> subSCs;
|
||||
subFilters->walk(execplan::getSimpleColsExtended, &subSCs);
|
||||
subFilters->walk(execplan::getSimpleCols, &subSCs);
|
||||
for (auto* sc : subSCs)
|
||||
{
|
||||
if (sc)
|
||||
@@ -674,7 +686,7 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
|
||||
if (auto subHaving = sub->having())
|
||||
{
|
||||
std::vector<execplan::SimpleColumn*> subSCs;
|
||||
subHaving->walk(execplan::getSimpleColsExtended, &subSCs);
|
||||
subHaving->walk(execplan::getSimpleCols, &subSCs);
|
||||
for (auto* sc : subSCs)
|
||||
{
|
||||
if (sc)
|
||||
|
||||
Reference in New Issue
Block a user