You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
fix(group by, having): MCOL-5776: GROUP BY/HAVING closer to server's (#3371)
This patch introduces an internal aggregate operator SELECT_SOME that is automatically added to columns that are not in GROUP BY. It "computes" some plausible value of the column (actually, last one passed). Along the way it fixes incorrect handling of HAVING being transferred into WHERE, window function handling and a bit of other inconsistencies.
This commit is contained in:
@ -46,6 +46,7 @@ using namespace joblist;
|
||||
|
||||
namespace execplan
|
||||
{
|
||||
|
||||
void getAggCols(execplan::ParseTree* n, void* obj)
|
||||
{
|
||||
vector<AggregateColumn*>* list = reinterpret_cast<vector<AggregateColumn*>*>(obj);
|
||||
|
@ -300,12 +300,12 @@ const string ArithmeticColumn::toString() const
|
||||
if (fAlias.length() > 0)
|
||||
oss << "Alias: " << fAlias << endl;
|
||||
|
||||
if (fExpression != 0)
|
||||
fExpression->walk(walkfn, oss);
|
||||
|
||||
oss << "expressionId=" << fExpressionId << endl;
|
||||
oss << "joinInfo=" << fJoinInfo << " returnAll=" << fReturnAll << " sequence#=" << fSequence << endl;
|
||||
oss << "resultType=" << colDataTypeToString(fResultType.colDataType) << "|" << fResultType.colWidth << endl;
|
||||
if (fExpression != 0)
|
||||
fExpression->walk(walkfn, oss);
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
@ -239,6 +239,10 @@ inline void ArithmeticOperator::evaluate(rowgroup::Row& row, bool& isNull, Parse
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
fResult.intVal = execute(lop->getIntVal(row, isNull), rop->getIntVal(row, isNull), isNull);
|
||||
if (isNull)
|
||||
{
|
||||
fResult.intVal = joblist::INTNULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
@ -292,6 +296,10 @@ inline void ArithmeticOperator::evaluate(rowgroup::Row& row, bool& isNull, Parse
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
fResult.uintVal = execute(lop->getUintVal(row, isNull), rop->getUintVal(row, isNull), isNull);
|
||||
if (isNull)
|
||||
{
|
||||
fResult.uintVal = joblist::UBIGINTNULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
|
@ -62,16 +62,14 @@ ConstantFilter::ConstantFilter(const SOP& op, ReturnedColumn* lhs, ReturnedColum
|
||||
{
|
||||
SSFP ssfp(new SimpleFilter(op, lhs, rhs));
|
||||
fFilterList.push_back(ssfp);
|
||||
SimpleColumn* sc = dynamic_cast<SimpleColumn*>(lhs);
|
||||
fCol.reset(sc->clone());
|
||||
fCol.reset(lhs->clone());
|
||||
}
|
||||
|
||||
ConstantFilter::ConstantFilter(SimpleFilter* sf)
|
||||
{
|
||||
SSFP ssfp(sf);
|
||||
fFilterList.push_back(ssfp);
|
||||
const SimpleColumn* sc = dynamic_cast<const SimpleColumn*>(sf->lhs());
|
||||
fCol.reset(sc->clone());
|
||||
fCol.reset(sf->lhs()->clone());
|
||||
}
|
||||
|
||||
ConstantFilter::ConstantFilter(const ConstantFilter& rhs) : Filter(rhs), fOp(rhs.fOp), fCol(rhs.fCol)
|
||||
|
@ -412,7 +412,7 @@ bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, ReturnedCol
|
||||
|
||||
int64_t val2 = rop->getIntVal(row, isNull);
|
||||
|
||||
return numericCompare(val1, val2) && !isNull;
|
||||
return !isNull && numericCompare(val1, val2);
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
|
@ -208,6 +208,13 @@ SimpleColumn::SimpleColumn(const SimpleColumn& rhs, const uint32_t sessionID)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleColumn::SimpleColumn(const ReturnedColumn& rhs, const uint32_t sessionID)
|
||||
: ReturnedColumn(rhs, sessionID)
|
||||
, fData(rhs.data())
|
||||
, fisColumnStore(true)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleColumn::~SimpleColumn()
|
||||
{
|
||||
}
|
||||
@ -270,7 +277,9 @@ const string SimpleColumn::toString() const
|
||||
<< returnAll() << delim << sequence() << delim << cardinality() << delim << joinInfo() << delim
|
||||
<< colSource() << delim << (isColumnStore() ? "ColumnStore" : "ForeignEngine") << delim
|
||||
<< colPosition() << delim << cs.getCharset().cs_name.str << delim << cs.getCharset().coll_name.str
|
||||
<< delim << endl;
|
||||
<< " inputindex/outputindex: " << fInputIndex << delim << fOutputIndex
|
||||
<< " eid " << fExpressionId
|
||||
<< endl;
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class SimpleColumn : public ReturnedColumn
|
||||
SimpleColumn(const std::string& schema, const std::string& table, const std::string& col,
|
||||
const bool isColumnStore, const uint32_t sessionID = 0, const int lower_case_table_names = 0);
|
||||
SimpleColumn(const SimpleColumn& rhs, const uint32_t sessionID = 0);
|
||||
SimpleColumn(const ReturnedColumn& rhs, const uint32_t sessionID = 0);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
Reference in New Issue
Block a user