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
feat(cbo,rules,QA): clean SC iface usage in various places
This commit is contained in:
@@ -1018,9 +1018,10 @@ execplan::SCSEP CalpontSelectExecutionPlan::cloneForTableWORecursiveSelects(
|
|||||||
for (const auto& rc : fReturnedCols)
|
for (const auto& rc : fReturnedCols)
|
||||||
{
|
{
|
||||||
rc->setSimpleColumnList();
|
rc->setSimpleColumnList();
|
||||||
for (auto* sc : rc->simpleColumnList())
|
for (auto* simpleColumn : rc->simpleColumnList())
|
||||||
{
|
{
|
||||||
if (targetTableAlias.weakerEq(*sc->singleTable()))
|
auto tableAlias = simpleColumn->singleTable();
|
||||||
|
if (tableAlias && targetTableAlias.weakerEq(*tableAlias))
|
||||||
{
|
{
|
||||||
newReturnedCols.push_back(SRCP(rc->clone()));
|
newReturnedCols.push_back(SRCP(rc->clone()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -529,7 +529,8 @@ void SimpleColumn::setDerivedTable()
|
|||||||
|
|
||||||
std::optional<CalpontSystemCatalog::TableAliasName> SimpleColumn::singleTable()
|
std::optional<CalpontSystemCatalog::TableAliasName> SimpleColumn::singleTable()
|
||||||
{
|
{
|
||||||
return {CalpontSystemCatalog::TableAliasName(fSchemaName, fTableName, fTableAlias, fViewName)};
|
return {
|
||||||
|
CalpontSystemCatalog::TableAliasName(fSchemaName, fTableName, fTableAlias, fViewName, fisColumnStore)};
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo move to inline
|
// @todo move to inline
|
||||||
@@ -759,21 +760,21 @@ void SimpleColumn::setSimpleColumnList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(std::vector<SimpleColumn*> simpleColumnList)
|
std::optional<CalpontSystemCatalog::TableAliasName> sameTableCheck(
|
||||||
|
std::vector<SimpleColumn*> simpleColumnList)
|
||||||
{
|
{
|
||||||
std::optional<CalpontSystemCatalog::TableAliasName> tan;
|
std::optional<CalpontSystemCatalog::TableAliasName> tan;
|
||||||
for (SimpleColumn* simpleColumn : simpleColumnList)
|
for (SimpleColumn* simpleColumn : simpleColumnList)
|
||||||
{
|
{
|
||||||
CalpontSystemCatalog::TableAliasName stan(
|
CalpontSystemCatalog::TableAliasName stan(simpleColumn->schemaName(), simpleColumn->tableName(),
|
||||||
simpleColumn->schemaName(), simpleColumn->tableName(),
|
simpleColumn->tableAlias(), simpleColumn->viewName());
|
||||||
simpleColumn->tableAlias(), simpleColumn->viewName());
|
|
||||||
|
|
||||||
if (!tan.has_value())
|
if (!tan.has_value())
|
||||||
tan = stan;
|
tan = stan;
|
||||||
else if (stan != tan)
|
else if (stan != tan)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tan;
|
return tan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ std::optional<FilterRangeBounds<T>> populateRangeBounds(execplan::SimpleColumn*
|
|||||||
FilterRangeBounds<T> bounds;
|
FilterRangeBounds<T> bounds;
|
||||||
|
|
||||||
// Loop over buckets to produce filter ranges
|
// Loop over buckets to produce filter ranges
|
||||||
|
// NB Currently Histogram_json_hb has the last bucket that has end as its start
|
||||||
for (size_t i = 0; i < numberOfUnionUnits - 1; ++i)
|
for (size_t i = 0; i < numberOfUnionUnits - 1; ++i)
|
||||||
{
|
{
|
||||||
auto bucket = columnStatistics.get_json_histogram().begin() + i * numberOfBucketsPerUnionUnit;
|
auto bucket = columnStatistics.get_json_histogram().begin() + i * numberOfBucketsPerUnionUnit;
|
||||||
@@ -210,15 +211,6 @@ std::optional<FilterRangeBounds<T>> populateRangeBounds(execplan::SimpleColumn*
|
|||||||
bounds.push_back({currentLowerBound, currentUpperBound});
|
bounds.push_back({currentLowerBound, currentUpperBound});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add last range
|
|
||||||
// NB despite the fact that currently Histogram_json_hb has the last bucket that has end as its start
|
|
||||||
// auto lastBucket =
|
|
||||||
// columnStatistics.get_json_histogram().begin() + (numberOfUnionUnits - 1) *
|
|
||||||
// numberOfBucketsPerUnionUnit;
|
|
||||||
// T currentLowerBound = *(uint32_t*)lastBucket->start_value.data();
|
|
||||||
// T currentUpperBound = *(uint32_t*)columnStatistics.get_last_bucket_end_endp().data();
|
|
||||||
// bounds.push_back({currentLowerBound, currentUpperBound});
|
|
||||||
|
|
||||||
for (auto& bound : bounds)
|
for (auto& bound : bounds)
|
||||||
{
|
{
|
||||||
std::cout << "Bound: " << bound.first << " " << bound.second << std::endl;
|
std::cout << "Bound: " << bound.first << " " << bound.second << std::endl;
|
||||||
@@ -351,9 +343,6 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, RBOptimizerCon
|
|||||||
newSC->schemaName("");
|
newSC->schemaName("");
|
||||||
newSC->tableAlias(newTableAlias);
|
newSC->tableAlias(newTableAlias);
|
||||||
newSC->colPosition(colPosition++);
|
newSC->colPosition(colPosition++);
|
||||||
// MB not needed
|
|
||||||
newSC->oid(0);
|
|
||||||
newSC->expressionId(4294967295);
|
|
||||||
newSC->alias(rc->alias());
|
newSC->alias(rc->alias());
|
||||||
newReturnedColumns.push_back(newSC);
|
newReturnedColumns.push_back(newSC);
|
||||||
}
|
}
|
||||||
@@ -386,49 +375,11 @@ bool applyParallelCES(execplan::CalpontSelectExecutionPlan& csep, RBOptimizerCon
|
|||||||
}
|
}
|
||||||
newReturnedColumns.push_back(rc);
|
newReturnedColumns.push_back(rc);
|
||||||
}
|
}
|
||||||
// This part is not used
|
|
||||||
// TODO support expressions
|
|
||||||
// Find SC for the RC
|
|
||||||
|
|
||||||
// auto rcCloned = boost::make_shared<execplan::SimpleColumn>(*rc, rc->sessionID());
|
|
||||||
// TODO timezone and result type are not copied
|
|
||||||
// TODO add specific ctor for this functionality
|
|
||||||
// If there is an alias in the map then it is a new derived table
|
|
||||||
|
|
||||||
// auto sc = dynamic_cast<execplan::SimpleColumn*>(rc.get());
|
|
||||||
// std::vector<execplan::SimpleColumn*> scs;
|
|
||||||
|
|
||||||
// std::cout << "Processing RC schema " << rc->schemaName() << " table " << rc->tableName() << " alias "
|
|
||||||
// << rc->tableAlias() << std::endl;
|
|
||||||
// for (auto& [tableAlias, aliasAndCounter] : tableAliasMap)
|
|
||||||
// {
|
|
||||||
// std::cout << "Processing table alias " << tableAlias << " new alias " << aliasAndCounter.first
|
|
||||||
// << " col position " << aliasAndCounter.second << std::endl;
|
|
||||||
// }
|
|
||||||
// auto newTableAliasAndColPositionCounter =
|
|
||||||
// tableAliasMap.find({sc->schemaName(), sc->tableName(), sc->tableAlias(), "", false});
|
|
||||||
// if (newTableAliasAndColPositionCounter == tableAliasMap.end())
|
|
||||||
// {
|
|
||||||
// std::cout << "The RC doesn't belong to any of the derived tables, so leave it intact" << std::endl;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// auto& [newTableAlias, colPosition] = newTableAliasAndColPositionCounter->second;
|
|
||||||
|
|
||||||
// sc->tableName("");
|
|
||||||
// sc->schemaName("");
|
|
||||||
// sc->tableAlias(newTableAlias);
|
|
||||||
// sc->colPosition(colPosition++);
|
|
||||||
|
|
||||||
// rcCloned->isColumnStore(true);
|
|
||||||
// rcCloned->colPosition(colPosition++);
|
|
||||||
// rcCloned->resultType(rc->resultType());
|
|
||||||
// newReturnedColumns.push_back(rcCloned);
|
|
||||||
}
|
}
|
||||||
// Remove the filters if necessary using csep.filters(nullptr) as they were pushed down to union units
|
// Remove the filters that are not necessary as they were pushed down to union units.
|
||||||
// But this is inappropriate for EXISTS filter and join conditions
|
// But this is inappropriate for some EXISTS filter and join conditions
|
||||||
// There must be no derived at this point, so we can replace it with the new derived table list
|
|
||||||
|
|
||||||
// WIP hardcoded query
|
// WIP hardcoded query with lhs,rhs being simple columns
|
||||||
if (csep.filters() && csep.filters()->data())
|
if (csep.filters() && csep.filters()->data())
|
||||||
{
|
{
|
||||||
auto* left = dynamic_cast<execplan::SimpleFilter*>(csep.filters()->data());
|
auto* left = dynamic_cast<execplan::SimpleFilter*>(csep.filters()->data());
|
||||||
|
|||||||
Reference in New Issue
Block a user