1
0
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:
drrtuy
2025-09-08 11:59:31 +00:00
parent ed2c89196b
commit f807ebcdfd
16 changed files with 39 additions and 195 deletions

View File

@@ -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 * Constructors/Destructors
*/ */
@@ -141,36 +129,18 @@ AggregateColumn::AggregateColumn(const AggregateColumn& rhs, const uint32_t sess
void AggregateColumn::setSimpleColumnList() void AggregateColumn::setSimpleColumnList()
{ {
fSimpleColumnList.clear(); fSimpleColumnList.clear();
return setSimpleColumnList_(false);
}
void AggregateColumn::setSimpleColumnListExtended()
{
fSimpleColumnListExtended.clear();
return setSimpleColumnList_(true);
}
void AggregateColumn::setSimpleColumnList_(const bool extractSCsfromAggCol)
{
for (const auto& parm : aggParms()) for (const auto& parm : aggParms())
{ {
if (!parm) if (!parm)
continue; continue;
auto aggParmsAsSCVec = (extractSCsfromAggCol) ? getSCsFromRCForExtended(parm) : getSCsFromRC(parm); parm->setSimpleColumnList();
for (auto* sc : parm->simpleColumnList())
for (auto* sc : aggParmsAsSCVec)
{ {
if (sc) if (sc)
{ {
if (extractSCsfromAggCol) fSimpleColumnList.push_back(sc);
{
fSimpleColumnListExtended.push_back(sc);
}
else
{
fSimpleColumnList.push_back(sc);
}
} }
} }
} }

View File

@@ -161,9 +161,7 @@ class AggregateColumn : public ReturnedColumn
fAggParms = parms; fAggParms = parms;
} }
void setSimpleColumnList_(const bool extractSCsfromAggCol);
void setSimpleColumnList() override; void setSimpleColumnList() override;
void setSimpleColumnListExtended() override;
/** return a copy of this pointer /** return a copy of this pointer
* *

View File

@@ -447,12 +447,6 @@ void ArithmeticColumn::setSimpleColumnList()
fExpression->walk(getSimpleCols, &fSimpleColumnList); fExpression->walk(getSimpleCols, &fSimpleColumnList);
} }
void ArithmeticColumn::setSimpleColumnListExtended()
{
fSimpleColumnListExtended.clear();
fExpression->walk(getSimpleColsExtended, &fSimpleColumnListExtended);
}
std::optional<CalpontSystemCatalog::TableAliasName> ArithmeticColumn::singleTable() std::optional<CalpontSystemCatalog::TableAliasName> ArithmeticColumn::singleTable()
{ {
setSimpleColumnList(); setSimpleColumnList();

View File

@@ -169,10 +169,12 @@ class ArithmeticColumn : public ReturnedColumn
void setDerivedTable() override; void setDerivedTable() override;
void replaceRealCol(std::vector<SRCP>&) override; void replaceRealCol(std::vector<SRCP>&) override;
const std::vector<SimpleColumn*>& simpleColumnList() const override
{
return fSimpleColumnList;
}
void setSimpleColumnList() override; void setSimpleColumnList() override;
void setSimpleColumnListExtended() override;
/** /**
* Return the table that the column arguments belong to. * Return the table that the column arguments belong to.
* *

View File

@@ -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 } // namespace execplan

View File

@@ -202,10 +202,8 @@ class ConstantFilter : public Filter
// get all simple columns involved in this column // get all simple columns involved in this column
const std::vector<SimpleColumn*>& simpleColumnList(); const std::vector<SimpleColumn*>& simpleColumnList();
const std::vector<SimpleColumn*>& simpleColumnListExtended();
// walk through the constant filter operands to re-populate fSimpleColumnList // walk through the constant filter operands to re-populate fSimpleColumnList
void setSimpleColumnList(); void setSimpleColumnList();
void setSimpleColumnListExtended();
// get all aggregate columns involved in this column // get all aggregate columns involved in this column
const std::vector<AggregateColumn*>& aggColumnList() const const std::vector<AggregateColumn*>& aggColumnList() const
@@ -215,7 +213,6 @@ class ConstantFilter : public Filter
private: private:
std::vector<SimpleColumn*> fSimpleColumnList; std::vector<SimpleColumn*> fSimpleColumnList;
std::vector<SimpleColumn*> fSimpleColumnListExtended{};
std::vector<AggregateColumn*> fAggColumnList; std::vector<AggregateColumn*> fAggColumnList;
std::vector<WindowFunctionColumn*> fWindowFunctionColumnList; std::vector<WindowFunctionColumn*> fWindowFunctionColumnList;
}; };

View File

@@ -46,6 +46,7 @@ using namespace boost;
#include "functor_str.h" #include "functor_str.h"
using namespace funcexp; using namespace funcexp;
namespace execplan namespace execplan
{ {
/** /**
@@ -140,8 +141,7 @@ string FunctionColumn::toCppCode(IncludeSet& includes) const
auto fFuncParmsInString = fData.substr(fFunctionName.size() + 1, fData.size() - fFunctionName.size() - 2); auto fFuncParmsInString = fData.substr(fFunctionName.size() + 1, fData.size() - fFunctionName.size() - 2);
ss << "FunctionColumn(" << std::quoted(fFunctionName) << ", " << std::quoted(fFuncParmsInString) << ", " ss << "FunctionColumn(" << std::quoted(fFunctionName) << ", " << std::quoted(fFuncParmsInString) << ", " << sessionID() << ")";
<< sessionID() << ")";
return ss.str(); return ss.str();
} }
@@ -521,14 +521,6 @@ void FunctionColumn::setSimpleColumnList()
fFunctionParms[i]->walk(getSimpleCols, &fSimpleColumnList); 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() std::optional<CalpontSystemCatalog::TableAliasName> FunctionColumn::singleTable()
{ {
setSimpleColumnList(); setSimpleColumnList();

View File

@@ -159,9 +159,12 @@ class FunctionColumn : public ReturnedColumn
bool hasWindowFunc() override; bool hasWindowFunc() override;
void setDerivedTable() override; void setDerivedTable() override;
void replaceRealCol(std::vector<SRCP>&) override; void replaceRealCol(std::vector<SRCP>&) override;
virtual const std::vector<SimpleColumn*>& simpleColumnList() const override
{
return fSimpleColumnList;
}
void setSimpleColumnList() override; void setSimpleColumnList() override;
void setSimpleColumnListExtended() override;
/** /**
* Return the tableAlias name of the table that the column arguments belong to. * Return the tableAlias name of the table that the column arguments belong to.
* *

View File

@@ -260,9 +260,4 @@ void ReturnedColumn::setSimpleColumnList()
fSimpleColumnList.clear(); fSimpleColumnList.clear();
} }
void ReturnedColumn::setSimpleColumnListExtended()
{
fSimpleColumnListExtended.clear();
}
} // namespace execplan } // namespace execplan

View File

@@ -287,11 +287,6 @@ class ReturnedColumn : public TreeNode
return fSimpleColumnList; return fSimpleColumnList;
} }
virtual const std::vector<SimpleColumn*>& simpleColumnListExtended() const
{
return fSimpleColumnListExtended;
}
/* @brief traverse this ReturnedColumn and re-populate fSimpleColumnList. /* @brief traverse this ReturnedColumn and re-populate fSimpleColumnList.
* *
* @note all ReturnedColumns that may have simple column arguments added * @note all ReturnedColumns that may have simple column arguments added
@@ -299,8 +294,6 @@ class ReturnedColumn : public TreeNode
*/ */
virtual void setSimpleColumnList(); virtual void setSimpleColumnList();
virtual void setSimpleColumnListExtended();
// get all aggregate column list in this expression // get all aggregate column list in this expression
const std::vector<AggregateColumn*>& aggColumnList() const 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 fOrderPos; /// for order by and group by column
uint64_t fColSource; /// from which subquery uint64_t fColSource; /// from which subquery
int64_t fColPosition; /// the column position in the source 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*> fSimpleColumnList;
std::vector<SimpleColumn*> fSimpleColumnListExtended{};
std::vector<AggregateColumn*> fAggColumnList; std::vector<AggregateColumn*> fAggColumnList;
std::vector<WindowFunctionColumn*> fWindowFunctionColumnList; std::vector<WindowFunctionColumn*> fWindowFunctionColumnList;
bool fHasAggregate; /// connector internal use. no need to serialize bool fHasAggregate; /// connector internal use. no need to serialize

View File

@@ -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* replaceRefCol(ParseTree*& n, CalpontSelectExecutionPlan::ReturnedColumnList& derivedColList)
{ {
ParseTree* lhs = n->left(); 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::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(
std::vector<SimpleColumn*> simpleColumnList) std::vector<SimpleColumn*> simpleColumnList)
{ {

View File

@@ -266,7 +266,7 @@ class SimpleColumn : public ReturnedColumn
std::optional<CalpontSystemCatalog::TableAliasName> singleTable() override; std::optional<CalpontSystemCatalog::TableAliasName> singleTable() override;
void setSimpleColumnList() override; void setSimpleColumnList() override;
void setSimpleColumnListExtended() override;
protected: 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 * utility function to extract all simple columns from a parse tree
*/ */
void getSimpleCols(ParseTree* n, void* obj); void getSimpleCols(ParseTree* n, void* obj);
void getSimpleColsExtended(execplan::ParseTree* n, void* obj);
ParseTree* replaceRefCol(ParseTree*& n, CalpontSelectExecutionPlan::ReturnedColumnList&); ParseTree* replaceRefCol(ParseTree*& n, CalpontSelectExecutionPlan::ReturnedColumnList&);
std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck( std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(std::vector<SimpleColumn*> simpleColumnList);
std::vector<SimpleColumn*> simpleColumnList);
} // namespace execplan } // namespace execplan

View File

@@ -810,11 +810,6 @@ const std::vector<SimpleColumn*>& SimpleFilter::simpleColumnList()
return fSimpleColumnList; return fSimpleColumnList;
} }
const std::vector<SimpleColumn*>& SimpleFilter::simpleColumnListExtended()
{
return fSimpleColumnListExtended;
}
void SimpleFilter::setSimpleColumnList() void SimpleFilter::setSimpleColumnList()
{ {
SimpleColumn* lsc = dynamic_cast<SimpleColumn*>(fLhs); 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() bool SimpleFilter::hasAggregate()
{ {
if (fAggColumnList.empty()) if (fAggColumnList.empty())

View File

@@ -246,10 +246,8 @@ class SimpleFilter : public Filter
// get all simple columns involved in this column // get all simple columns involved in this column
const std::vector<SimpleColumn*>& simpleColumnList(); const std::vector<SimpleColumn*>& simpleColumnList();
const std::vector<SimpleColumn*>& simpleColumnListExtended();
// walk through the simple filter operands to re-populate fSimpleColumnList // walk through the simple filter operands to re-populate fSimpleColumnList
void setSimpleColumnList(); void setSimpleColumnList();
void setSimpleColumnListExtended();
// walk through the simple filter operands to check existence of aggregate // walk through the simple filter operands to check existence of aggregate
bool hasAggregate(); bool hasAggregate();
@@ -267,7 +265,6 @@ class SimpleFilter : public Filter
private: private:
std::vector<SimpleColumn*> fSimpleColumnList; std::vector<SimpleColumn*> fSimpleColumnList;
std::vector<SimpleColumn*> fSimpleColumnListExtended{};
std::vector<AggregateColumn*> fAggColumnList; std::vector<AggregateColumn*> fAggColumnList;
std::vector<WindowFunctionColumn*> fWindowFunctionColumnList; std::vector<WindowFunctionColumn*> fWindowFunctionColumnList;
}; };

View File

@@ -67,6 +67,8 @@ uint32_t uniqTupleKey(JobInfo& jobInfo, CalpontSystemCatalog::OID& o, CalpontSys
return iter->second; return iter->second;
uint32_t newId = jobInfo.keyInfo->nextKey++; uint32_t newId = jobInfo.keyInfo->nextKey++;
// cout << "new id: " << newId << " -- " << o << ", " << pi << ", " << nm << ", " << vw << ", " << sn << ",
// " << subId << endl;
jobInfo.keyInfo->tupleKeyMap[id] = newId; jobInfo.keyInfo->tupleKeyMap[id] = newId;
jobInfo.keyInfo->tupleKeyVec.push_back(id); jobInfo.keyInfo->tupleKeyVec.push_back(id);
jobInfo.keyInfo->tupleKeyToTableOid.insert(make_pair(newId, t)); jobInfo.keyInfo->tupleKeyToTableOid.insert(make_pair(newId, t));

View File

@@ -523,15 +523,27 @@ void tryToUpdateScToUseRewrittenDerived(
} }
void updateSCsUsingIteration(optimizer::TableAliasToNewAliasAndSCPositionsMap& tableAliasToSCPositionsMap, void updateSCsUsingIteration(optimizer::TableAliasToNewAliasAndSCPositionsMap& tableAliasToSCPositionsMap,
std::vector<execplan::SRCP>& rcs) std::vector<execplan::SRCP>& rcs, const bool ignoreAgg)
{ {
for (auto& rc : rcs) for (auto& rc : rcs)
{ {
rc->setSimpleColumnListExtended(); rc->setSimpleColumnList();
for (auto* sc : rc->simpleColumnListExtended()) for (auto* sc : rc->simpleColumnList())
{ {
tryToUpdateScToUseRewrittenDerived(sc, tableAliasToSCPositionsMap); 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) execplan::ParseTree* pt)
{ {
std::vector<execplan::SimpleColumn*> simpleColumns; std::vector<execplan::SimpleColumn*> simpleColumns;
pt->walk(execplan::getSimpleColsExtended, &simpleColumns); pt->walk(execplan::getSimpleCols, &simpleColumns);
for (auto* sc : simpleColumns) for (auto* sc : simpleColumns)
{ {
tryToUpdateScToUseRewrittenDerived(sc, tableAliasToSCPositionsMap); tryToUpdateScToUseRewrittenDerived(sc, tableAliasToSCPositionsMap);
@@ -610,7 +622,7 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
{ {
for (auto& rc : csep.returnedCols()) for (auto& rc : csep.returnedCols())
{ {
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.returnedCols()); updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.returnedCols(), false);
newReturnedColumns.push_back(rc); newReturnedColumns.push_back(rc);
} }
@@ -621,13 +633,13 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
// 3d pass over GROUP BY columns // 3d pass over GROUP BY columns
if (!csep.groupByCols().empty()) if (!csep.groupByCols().empty())
{ {
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.groupByCols()); updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.groupByCols(), true);
} }
// 4th pass over ORDER BY columns // 4th pass over ORDER BY columns
if (!csep.orderByCols().empty()) if (!csep.orderByCols().empty())
{ {
updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.orderByCols()); updateSCsUsingIteration(tableAliasToSCPositionsMap, csep.orderByCols(), false);
} }
// 5th pass over filters to use derived table SCs in filters // 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()) if (auto subFilters = sub->filters())
{ {
std::vector<execplan::SimpleColumn*> subSCs; std::vector<execplan::SimpleColumn*> subSCs;
subFilters->walk(execplan::getSimpleColsExtended, &subSCs); subFilters->walk(execplan::getSimpleCols, &subSCs);
for (auto* sc : subSCs) for (auto* sc : subSCs)
{ {
if (sc) if (sc)
@@ -674,7 +686,7 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, optimizer::RBO
if (auto subHaving = sub->having()) if (auto subHaving = sub->having())
{ {
std::vector<execplan::SimpleColumn*> subSCs; std::vector<execplan::SimpleColumn*> subSCs;
subHaving->walk(execplan::getSimpleColsExtended, &subSCs); subHaving->walk(execplan::getSimpleCols, &subSCs);
for (auto* sc : subSCs) for (auto* sc : subSCs)
{ {
if (sc) if (sc)