You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
Merge pull request #808 from mariadb-corporation/develop-merge-up-20190729
Merge develop-1.2 into develop
This commit is contained in:
@@ -566,17 +566,11 @@ assignment_commalist:
|
||||
assignment:
|
||||
column COMPARISON scalar_exp
|
||||
{
|
||||
$$ = new ColumnAssignment();
|
||||
$$->fColumn = $1;
|
||||
$$->fOperator = $2;
|
||||
$$->fScalarExpression = $3;
|
||||
$$ = new ColumnAssignment($1, $2, $3);
|
||||
}
|
||||
| column COMPARISON NULLX
|
||||
{
|
||||
$$ = new ColumnAssignment();
|
||||
$$->fColumn = $1;
|
||||
$$->fOperator = $2;
|
||||
$$->fScalarExpression = $3;
|
||||
$$ = new ColumnAssignment($1, $2, $3);
|
||||
}
|
||||
;
|
||||
|
||||
|
@@ -409,6 +409,14 @@ public:
|
||||
class ColumnAssignment
|
||||
{
|
||||
public:
|
||||
explicit ColumnAssignment(
|
||||
std::string const& column,
|
||||
std::string const& op = "=",
|
||||
std::string const& expr = "") :
|
||||
fColumn(column), fOperator(op), fScalarExpression(expr),
|
||||
fFromCol(false), fFuncScale(0), fIsNull(false)
|
||||
{};
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
std::ostream& put(std::ostream& os) const;
|
||||
@@ -423,6 +431,7 @@ public:
|
||||
std::string fScalarExpression;
|
||||
bool fFromCol;
|
||||
uint32_t fFuncScale;
|
||||
bool fIsNull;
|
||||
};
|
||||
|
||||
/** @brief Stores a value list or a query specification
|
||||
|
@@ -259,7 +259,8 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* colaPtr = *iter;
|
||||
DMLColumn* colPtr = new DMLColumn(colaPtr->fColumn, colaPtr->fScalarExpression, colaPtr->fFromCol, colaPtr->fFuncScale);
|
||||
DMLColumn* colPtr = new DMLColumn(colaPtr->fColumn, colaPtr->fScalarExpression, colaPtr->fFromCol, colaPtr->fFuncScale,
|
||||
colaPtr->fIsNull);
|
||||
rowPtr->get_ColumnList().push_back(colPtr);
|
||||
|
||||
++iter;
|
||||
|
@@ -326,7 +326,8 @@ void ArithmeticColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
ObjectReader::writeParseTree(fExpression, b);
|
||||
b << fTableAlias;
|
||||
b << fData;
|
||||
b << static_cast<const ByteStream::doublebyte>(fAsc);
|
||||
const ByteStream::doublebyte tmp = fAsc;
|
||||
b << tmp;
|
||||
}
|
||||
|
||||
void ArithmeticColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
@@ -340,7 +341,9 @@ void ArithmeticColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
fExpression = ObjectReader::createParseTree(b);
|
||||
b >> fTableAlias;
|
||||
b >> fData;
|
||||
b >> reinterpret_cast< ByteStream::doublebyte&>(fAsc);
|
||||
ByteStream::doublebyte tmp;
|
||||
b >> tmp;
|
||||
fAsc = (tmp);
|
||||
|
||||
fSimpleColumnList.clear();
|
||||
fExpression->walk(getSimpleCols, &fSimpleColumnList);
|
||||
|
@@ -548,6 +548,10 @@ public:
|
||||
return fDerivedTbAlias;
|
||||
}
|
||||
|
||||
void derivedTbView(const std::string derivedTbView) { fDerivedTbView = derivedTbView; }
|
||||
const std::string derivedTbView() const { return fDerivedTbView; }
|
||||
|
||||
|
||||
void limitStart(const uint64_t limitStart)
|
||||
{
|
||||
fLimitStart = limitStart;
|
||||
@@ -870,6 +874,7 @@ private:
|
||||
// for subselect
|
||||
uint64_t fSubType;
|
||||
std::string fDerivedTbAlias;
|
||||
std::string fDerivedTbView;
|
||||
|
||||
// for limit
|
||||
uint64_t fLimitStart;
|
||||
|
@@ -426,6 +426,16 @@ void FunctionColumn::setDerivedTable()
|
||||
break;
|
||||
}
|
||||
}
|
||||
// MCOL-3239 Block for func column with both
|
||||
// derived table column and normal table column.
|
||||
else if (derivedTableAlias == "")
|
||||
{
|
||||
if (sc->tableAlias().length())
|
||||
{
|
||||
derivedTableAlias = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fDerivedTable = derivedTableAlias;
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
#include "expressionparser.h"
|
||||
#include "returnedcolumn.h"
|
||||
@@ -486,20 +485,16 @@ inline bool PredicateOperator::getBoolVal(rowgroup::Row& row, bool& isNull, Retu
|
||||
return !ret;
|
||||
}
|
||||
|
||||
// MCOL-1559
|
||||
std::string val1 = lop->getStrVal(row, isNull);
|
||||
if (isNull)
|
||||
return false;
|
||||
|
||||
std::string val2 = rop->getStrVal(row, isNull);
|
||||
const std::string& val1 = lop->getStrVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
return false;
|
||||
|
||||
boost::trim_right_if(val1, boost::is_any_of(" "));
|
||||
boost::trim_right_if(val2, boost::is_any_of(" "));
|
||||
|
||||
return strCompare(val1, val2);
|
||||
}
|
||||
return strCompare(val1, rop->getStrVal(row, isNull)) && !isNull;
|
||||
}
|
||||
|
||||
//FIXME: ???
|
||||
case execplan::CalpontSystemCatalog::VARBINARY:
|
||||
|
@@ -212,9 +212,9 @@ const string SimpleColumn::data() const
|
||||
if (!fData.empty())
|
||||
return fData;
|
||||
else if (!fTableAlias.empty())
|
||||
return string(fSchemaName + '.' + fTableAlias + '.' + fColumnName);
|
||||
return string("`" + fSchemaName + "`.`" + fTableAlias + "`.`" + fColumnName + "`");
|
||||
|
||||
return string(fSchemaName + '.' + fTableName + '.' + fColumnName);
|
||||
return string("`" + fSchemaName + "`.`" + fTableName + "`.`" + fColumnName + "`");
|
||||
}
|
||||
|
||||
SimpleColumn& SimpleColumn::operator=(const SimpleColumn& rhs)
|
||||
|
@@ -731,17 +731,17 @@ void CrossEngineStep::setProjectBPP(JobStep* jobStep1, JobStep*)
|
||||
else
|
||||
fSelectClause += "SELECT ";
|
||||
|
||||
fSelectClause += jobStep1->name();
|
||||
fSelectClause += "`" + jobStep1->name() + "`";
|
||||
}
|
||||
|
||||
|
||||
std::string CrossEngineStep::makeQuery()
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << fSelectClause << " FROM " << fTable;
|
||||
oss << fSelectClause << " FROM `" << fTable << "`";
|
||||
|
||||
if (fTable.compare(fAlias) != 0)
|
||||
oss << " " << fAlias;
|
||||
oss << " `" << fAlias << "`";
|
||||
|
||||
if (!fWhereClause.empty())
|
||||
oss << fWhereClause;
|
||||
|
@@ -386,19 +386,57 @@ CalpontSystemCatalog::OID tableOid(const SimpleColumn* sc, boost::shared_ptr<Cal
|
||||
return p.objnum;
|
||||
}
|
||||
|
||||
|
||||
uint32_t getTupleKey(const JobInfo& jobInfo,
|
||||
const execplan::SimpleColumn* sc)
|
||||
uint32_t getTupleKey(JobInfo& jobInfo,
|
||||
const execplan::SimpleColumn* sc,
|
||||
bool add)
|
||||
{
|
||||
int key = -1;
|
||||
const PseudoColumn* pc = dynamic_cast<const execplan::PseudoColumn*>(sc);
|
||||
uint32_t pseudoType = (pc) ? pc->pseudoType() : execplan::PSEUDO_UNKNOWN;
|
||||
return getTupleKey_(jobInfo, sc->oid(), sc->columnName(), extractTableAlias(sc),
|
||||
sc->schemaName(), sc->viewName(),
|
||||
((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0),
|
||||
pseudoType, (sc->isInfiniDB() ? 0 : 1));
|
||||
if (sc == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (add)
|
||||
{
|
||||
// setTupleInfo first if add is true, ok if already set.
|
||||
if (sc->schemaName().empty())
|
||||
{
|
||||
SimpleColumn tmp(*sc, jobInfo.sessionId);
|
||||
tmp.oid(tableOid(sc, jobInfo.csc) + 1 + sc->colPosition());
|
||||
key = getTupleKey(jobInfo, &tmp); // sub-query should be there
|
||||
}
|
||||
else
|
||||
{
|
||||
CalpontSystemCatalog::ColType ct = sc->colType();
|
||||
string alias(extractTableAlias(sc));
|
||||
CalpontSystemCatalog::OID tblOid = tableOid(sc, jobInfo.csc);
|
||||
TupleInfo ti(setTupleInfo(ct, sc->oid(), jobInfo, tblOid, sc, alias));
|
||||
key = ti.key;
|
||||
|
||||
CalpontSystemCatalog::OID dictOid = isDictCol(ct);
|
||||
|
||||
if (dictOid > 0)
|
||||
{
|
||||
ti = setTupleInfo(ct, dictOid, jobInfo, tblOid, sc, alias);
|
||||
jobInfo.keyInfo->dictKeyMap[key] = ti.key;
|
||||
key = ti.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TupleInfo is expected to be set already
|
||||
return getTupleKey_(jobInfo, sc->oid(), sc->columnName(), extractTableAlias(sc),
|
||||
sc->schemaName(), sc->viewName(),
|
||||
((sc->joinInfo() & execplan::JOIN_CORRELATED) != 0),
|
||||
pseudoType, (sc->isInfiniDB() ? 0 : 1));
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t getTupleKey(JobInfo& jobInfo, const SRCP& srcp, bool add)
|
||||
{
|
||||
int key = -1;
|
||||
@@ -608,7 +646,7 @@ uint32_t getExpTupleKey(const JobInfo& jobInfo, uint64_t eid, bool cr)
|
||||
}
|
||||
|
||||
|
||||
void addAggregateColumn(AggregateColumn* agc, int idx, RetColsVector& vec, JobInfo& jobInfo)
|
||||
void addAggregateColumn(ReturnedColumn* agc, int idx, RetColsVector& vec, JobInfo& jobInfo)
|
||||
{
|
||||
uint32_t eid = agc->expressionId();
|
||||
setExpTupleInfo(agc->resultType(), eid, agc->alias(), jobInfo);
|
||||
|
@@ -402,8 +402,9 @@ execplan::CalpontSystemCatalog::OID tableOid(const execplan::SimpleColumn* sc,
|
||||
/** @brief Returns the unique ID to be used in tupleInfo
|
||||
*
|
||||
*/
|
||||
uint32_t getTupleKey(const JobInfo& jobInfo,
|
||||
const execplan::SimpleColumn* sc);
|
||||
uint32_t getTupleKey(JobInfo& jobInfo,
|
||||
const execplan::SimpleColumn* sc,
|
||||
bool add = false);
|
||||
uint32_t getTableKey(const JobInfo& jobInfo,
|
||||
execplan::CalpontSystemCatalog::OID tableOid,
|
||||
const std::string& alias,
|
||||
@@ -465,7 +466,7 @@ TupleInfo setExpTupleInfo(const execplan::ReturnedColumn* rc, JobInfo& jobInfo);
|
||||
/** @brief add an aggregate column info
|
||||
*
|
||||
*/
|
||||
void addAggregateColumn(execplan::AggregateColumn*, int, RetColsVector&, JobInfo&);
|
||||
void addAggregateColumn(execplan::ReturnedColumn*, int, RetColsVector&, JobInfo&);
|
||||
|
||||
void makeJobSteps(execplan::CalpontSelectExecutionPlan* csep, JobInfo& jobInfo,
|
||||
JobStepVector& querySteps, JobStepVector& projectSteps,
|
||||
|
@@ -1644,6 +1644,7 @@ const JobStepVector doSimpleFilter(SimpleFilter* sf, JobInfo& jobInfo)
|
||||
|
||||
string constval(cc->constval());
|
||||
|
||||
|
||||
CalpontSystemCatalog::OID dictOid = 0;
|
||||
CalpontSystemCatalog::ColType ct = sc->colType();
|
||||
const PseudoColumn* pc = dynamic_cast<const PseudoColumn*>(sc);
|
||||
|
@@ -275,9 +275,11 @@ const JobStepVector doProject(const RetColsVector& retCols, JobInfo& jobInfo)
|
||||
|
||||
if (retCols[i]->windowfunctionColumnList().size() > 0)
|
||||
jobInfo.expressionVec.push_back(key);
|
||||
else if (find(jobInfo.expressionVec.begin(), jobInfo.expressionVec.end(), key) ==
|
||||
jobInfo.expressionVec.end())
|
||||
else if (find(jobInfo.expressionVec.begin(), jobInfo.expressionVec.end(), key)
|
||||
== jobInfo.expressionVec.end())
|
||||
{
|
||||
jobInfo.returnedExpressions.push_back(sjstep);
|
||||
}
|
||||
|
||||
//put place hold column in projection list
|
||||
jobInfo.pjColList.push_back(ti);
|
||||
@@ -427,7 +429,7 @@ void preProcessFunctionOnAggregation(const vector<SimpleColumn*>& scs,
|
||||
}
|
||||
}
|
||||
|
||||
// append the aggregate columns in arithmetic/function cloulmn to the projection list
|
||||
// append the aggregate columns in arithmetic/function column to the projection list
|
||||
for (vector<AggregateColumn*>::const_iterator i = aggs.begin(); i != aggs.end(); i++)
|
||||
{
|
||||
addAggregateColumn(*i, -1, jobInfo.projectionCols, jobInfo);
|
||||
@@ -1043,16 +1045,21 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo
|
||||
const FunctionColumn* fc = NULL;
|
||||
const WindowFunctionColumn* wc = NULL;
|
||||
bool hasAggCols = false;
|
||||
bool hasWndCols = false;
|
||||
|
||||
if ((ac = dynamic_cast<const ArithmeticColumn*>(srcp.get())) != NULL)
|
||||
{
|
||||
if (ac->aggColumnList().size() > 0)
|
||||
hasAggCols = true;
|
||||
if (ac->windowfunctionColumnList().size() > 0)
|
||||
hasWndCols = true;
|
||||
}
|
||||
else if ((fc = dynamic_cast<const FunctionColumn*>(srcp.get())) != NULL)
|
||||
{
|
||||
if (fc->aggColumnList().size() > 0)
|
||||
hasAggCols = true;
|
||||
if (fc->windowfunctionColumnList().size() > 0)
|
||||
hasWndCols = true;
|
||||
}
|
||||
else if (dynamic_cast<const AggregateColumn*>(srcp.get()) != NULL)
|
||||
{
|
||||
@@ -1077,7 +1084,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo
|
||||
TupleInfo ti(setExpTupleInfo(ct, eid, srcp.get()->alias(), jobInfo));
|
||||
tupleKey = ti.key;
|
||||
|
||||
if (hasAggCols)
|
||||
if (hasAggCols && !hasWndCols)
|
||||
jobInfo.expressionVec.push_back(tupleKey);
|
||||
}
|
||||
|
||||
@@ -1191,16 +1198,21 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo
|
||||
const FunctionColumn* fc = NULL;
|
||||
const WindowFunctionColumn* wc = NULL;
|
||||
bool hasAggCols = false;
|
||||
bool hasWndCols = false;
|
||||
|
||||
if ((ac = dynamic_cast<const ArithmeticColumn*>(srcp.get())) != NULL)
|
||||
{
|
||||
if (ac->aggColumnList().size() > 0)
|
||||
hasAggCols = true;
|
||||
if (ac->windowfunctionColumnList().size() > 0)
|
||||
hasWndCols = true;
|
||||
}
|
||||
else if ((fc = dynamic_cast<const FunctionColumn*>(srcp.get())) != NULL)
|
||||
{
|
||||
if (fc->aggColumnList().size() > 0)
|
||||
hasAggCols = true;
|
||||
if (fc->windowfunctionColumnList().size() > 0)
|
||||
hasWndCols = true;
|
||||
}
|
||||
else if (dynamic_cast<const AggregateColumn*>(srcp.get()) != NULL)
|
||||
{
|
||||
@@ -1225,7 +1237,7 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo
|
||||
TupleInfo ti(setExpTupleInfo(ct, eid, srcp.get()->alias(), jobInfo));
|
||||
tupleKey = ti.key;
|
||||
|
||||
if (hasAggCols)
|
||||
if (hasAggCols && !hasWndCols)
|
||||
jobInfo.expressionVec.push_back(tupleKey);
|
||||
}
|
||||
|
||||
|
@@ -750,7 +750,6 @@ bool LBIDList::CasualPartitionPredicate(const int64_t Min,
|
||||
int64_t tMax = Max;
|
||||
dataconvert::DataConvert::trimWhitespace(tMin);
|
||||
dataconvert::DataConvert::trimWhitespace(tMax);
|
||||
dataconvert::DataConvert::trimWhitespace(value);
|
||||
|
||||
scan = compareVal(order_swap(tMin), order_swap(tMax), order_swap(value),
|
||||
op, lcf);
|
||||
|
@@ -1410,7 +1410,7 @@ void TupleAggregateStep::prep1PhaseAggregate(
|
||||
typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAgg.push_back(-1);
|
||||
widthAgg.push_back(sizeof(long double));
|
||||
scaleAgg.push_back(scaleProj[colProj]);
|
||||
scaleAgg.push_back(0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1588,8 +1588,8 @@ void TupleAggregateStep::prep1PhaseAggregate(
|
||||
}
|
||||
|
||||
functionVec[i]->fAuxColumnIndex = lastCol++;
|
||||
oidsAgg.push_back(oidsAgg[j]);
|
||||
keysAgg.push_back(keysAgg[j]);
|
||||
oidsAgg.push_back(oidsProj[j]);
|
||||
keysAgg.push_back(keysProj[j]);
|
||||
scaleAgg.push_back(0);
|
||||
precisionAgg.push_back(0);
|
||||
precisionAgg.push_back(0);
|
||||
@@ -1604,8 +1604,8 @@ void TupleAggregateStep::prep1PhaseAggregate(
|
||||
functionVec[i]->fAuxColumnIndex = lastCol;
|
||||
|
||||
// sum(x)
|
||||
oidsAgg.push_back(oidsAgg[j]);
|
||||
keysAgg.push_back(keysAgg[j]);
|
||||
oidsAgg.push_back(oidsProj[j]);
|
||||
keysAgg.push_back(keysProj[j]);
|
||||
scaleAgg.push_back(0);
|
||||
precisionAgg.push_back(-1);
|
||||
typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -1613,8 +1613,8 @@ void TupleAggregateStep::prep1PhaseAggregate(
|
||||
++lastCol;
|
||||
|
||||
// sum(x**2)
|
||||
oidsAgg.push_back(oidsAgg[j]);
|
||||
keysAgg.push_back(keysAgg[j]);
|
||||
oidsAgg.push_back(oidsProj[j]);
|
||||
keysAgg.push_back(keysProj[j]);
|
||||
scaleAgg.push_back(0);
|
||||
precisionAgg.push_back(-1);
|
||||
typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -1942,7 +1942,7 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
typeAgg.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAgg.push_back(-1);
|
||||
widthAgg.push_back(sizeof(long double));
|
||||
scaleAgg.push_back(scaleProj[colProj]);
|
||||
scaleAgg.push_back(0);
|
||||
colAgg++;
|
||||
|
||||
// has distinct step, put the count column for avg next to the sum
|
||||
@@ -2264,7 +2264,7 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAggDist.push_back(-1);
|
||||
widthAggDist.push_back(sizeof(long double));
|
||||
scaleAggDist.push_back(scaleProj[colAgg]);
|
||||
scaleAggDist.push_back(0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2336,10 +2336,10 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
{
|
||||
oidsAggDist.push_back(oidsAgg[colAgg]);
|
||||
keysAggDist.push_back(retKey);
|
||||
scaleAggDist.push_back(scaleAgg[colAgg] >> 8);
|
||||
precisionAggDist.push_back(precisionAgg[colAgg]);
|
||||
typeAggDist.push_back(typeAgg[colAgg]);
|
||||
widthAggDist.push_back(widthAgg[colAgg]);
|
||||
scaleAggDist.push_back(0);
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAggDist.push_back(-1);
|
||||
widthAggDist.push_back(sizeof(long double));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2631,8 +2631,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
functionVec2[i]->fAuxColumnIndex = lastCol;
|
||||
|
||||
// sum(x)
|
||||
oidsAggDist.push_back(oidsAggDist[j]);
|
||||
keysAggDist.push_back(keysAggDist[j]);
|
||||
oidsAggDist.push_back(oidsAgg[j]);
|
||||
keysAggDist.push_back(keysAgg[j]);
|
||||
scaleAggDist.push_back(0);
|
||||
precisionAggDist.push_back(0);
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -2640,8 +2640,8 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
++lastCol;
|
||||
|
||||
// sum(x**2)
|
||||
oidsAggDist.push_back(oidsAggDist[j]);
|
||||
keysAggDist.push_back(keysAggDist[j]);
|
||||
oidsAggDist.push_back(oidsAgg[j]);
|
||||
keysAggDist.push_back(keysAgg[j]);
|
||||
scaleAggDist.push_back(0);
|
||||
precisionAggDist.push_back(-1);
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -3188,7 +3188,7 @@ void TupleAggregateStep::prep2PhasesAggregate(
|
||||
oidsAggPm.push_back(oidsProj[colProj]);
|
||||
keysAggPm.push_back(aggKey);
|
||||
typeAggPm.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
scaleAggPm.push_back(scaleProj[colProj]);
|
||||
scaleAggPm.push_back(0);
|
||||
precisionAggPm.push_back(-1);
|
||||
widthAggPm.push_back(sizeof(long double));
|
||||
colAggPm++;
|
||||
@@ -3465,10 +3465,10 @@ void TupleAggregateStep::prep2PhasesAggregate(
|
||||
{
|
||||
oidsAggUm.push_back(oidsAggPm[colPm]);
|
||||
keysAggUm.push_back(retKey);
|
||||
scaleAggUm.push_back(scaleAggPm[colPm] >> 8);
|
||||
precisionAggUm.push_back(precisionAggPm[colPm]);
|
||||
typeAggUm.push_back(typeAggPm[colPm]);
|
||||
widthAggUm.push_back(widthAggPm[colPm]);
|
||||
scaleAggUm.push_back(0);
|
||||
typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAggUm.push_back(-1);
|
||||
widthAggUm.push_back(sizeof(long double));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3683,8 +3683,8 @@ void TupleAggregateStep::prep2PhasesAggregate(
|
||||
functionVecUm[i]->fAuxColumnIndex = lastCol;
|
||||
|
||||
// sum(x)
|
||||
oidsAggUm.push_back(oidsAggUm[j]);
|
||||
keysAggUm.push_back(keysAggUm[j]);
|
||||
oidsAggUm.push_back(oidsAggPm[j]);
|
||||
keysAggUm.push_back(keysAggPm[j]);
|
||||
scaleAggUm.push_back(0);
|
||||
precisionAggUm.push_back(-1);
|
||||
typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -3692,8 +3692,8 @@ void TupleAggregateStep::prep2PhasesAggregate(
|
||||
++lastCol;
|
||||
|
||||
// sum(x**2)
|
||||
oidsAggUm.push_back(oidsAggUm[j]);
|
||||
keysAggUm.push_back(keysAggUm[j]);
|
||||
oidsAggUm.push_back(oidsAggPm[j]);
|
||||
keysAggUm.push_back(keysAggPm[j]);
|
||||
scaleAggUm.push_back(0);
|
||||
precisionAggUm.push_back(-1);
|
||||
typeAggUm.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -4046,7 +4046,7 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
typeAggPm.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAggPm.push_back(-1);
|
||||
widthAggPm.push_back(sizeof(long double));
|
||||
scaleAggPm.push_back(scaleProj[colProj]);
|
||||
scaleAggPm.push_back(0);
|
||||
colAggPm++;
|
||||
}
|
||||
|
||||
@@ -4415,7 +4415,7 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAggDist.push_back(-1);
|
||||
widthAggDist.push_back(sizeof(long double));
|
||||
scaleAggDist.push_back(scaleAggUm[colUm]);
|
||||
scaleAggDist.push_back(0);
|
||||
}
|
||||
// PM: put the count column for avg next to the sum
|
||||
// let fall through to add a count column for average function
|
||||
@@ -4477,10 +4477,10 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
{
|
||||
oidsAggDist.push_back(oidsAggUm[colUm]);
|
||||
keysAggDist.push_back(retKey);
|
||||
scaleAggDist.push_back(scaleAggUm[colUm] >> 8);
|
||||
precisionAggDist.push_back(precisionAggUm[colUm]);
|
||||
typeAggDist.push_back(typeAggUm[colUm]);
|
||||
widthAggDist.push_back(widthAggUm[colUm]);
|
||||
scaleAggDist.push_back(0);
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
precisionAggDist.push_back(-1);
|
||||
widthAggDist.push_back(sizeof(long double));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4725,8 +4725,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
functionVecUm[i]->fAuxColumnIndex = lastCol;
|
||||
|
||||
// sum(x)
|
||||
oidsAggDist.push_back(oidsAggDist[j]);
|
||||
keysAggDist.push_back(keysAggDist[j]);
|
||||
oidsAggDist.push_back(oidsAggPm[j]);
|
||||
keysAggDist.push_back(keysAggPm[j]);
|
||||
scaleAggDist.push_back(0);
|
||||
precisionAggDist.push_back(-1);
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -4734,8 +4734,8 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
++lastCol;
|
||||
|
||||
// sum(x**2)
|
||||
oidsAggDist.push_back(oidsAggDist[j]);
|
||||
keysAggDist.push_back(keysAggDist[j]);
|
||||
oidsAggDist.push_back(oidsAggPm[j]);
|
||||
keysAggDist.push_back(keysAggPm[j]);
|
||||
scaleAggDist.push_back(0);
|
||||
precisionAggDist.push_back(-1);
|
||||
typeAggDist.push_back(CalpontSystemCatalog::LONGDOUBLE);
|
||||
@@ -5038,7 +5038,8 @@ void TupleAggregateStep::prepExpressionOnAggregate(SP_ROWAGG_UM_t& aggUM, JobInf
|
||||
uint64_t eid = -1;
|
||||
|
||||
if (((ac = dynamic_cast<ArithmeticColumn*>(it->get())) != NULL) &&
|
||||
(ac->aggColumnList().size() > 0))
|
||||
(ac->aggColumnList().size() > 0) &&
|
||||
(ac->windowfunctionColumnList().size() == 0))
|
||||
{
|
||||
const vector<SimpleColumn*>& scols = ac->simpleColumnList();
|
||||
simpleColumns.insert(simpleColumns.end(), scols.begin(), scols.end());
|
||||
@@ -5047,7 +5048,8 @@ void TupleAggregateStep::prepExpressionOnAggregate(SP_ROWAGG_UM_t& aggUM, JobInf
|
||||
expressionVec.push_back(*it);
|
||||
}
|
||||
else if (((fc = dynamic_cast<FunctionColumn*>(it->get())) != NULL) &&
|
||||
(fc->aggColumnList().size() > 0))
|
||||
(fc->aggColumnList().size() > 0) &&
|
||||
(fc->windowfunctionColumnList().size() == 0))
|
||||
{
|
||||
const vector<SimpleColumn*>& sCols = fc->simpleColumnList();
|
||||
simpleColumns.insert(simpleColumns.end(), sCols.begin(), sCols.end());
|
||||
|
@@ -320,6 +320,41 @@ const string WindowFunctionStep::toString() const
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void WindowFunctionStep::AddSimplColumn(const vector<SimpleColumn*>& scs,
|
||||
JobInfo& jobInfo)
|
||||
{
|
||||
// append the simple columns if not already projected
|
||||
set<UniqId> scProjected;
|
||||
|
||||
for (RetColsVector::iterator i = jobInfo.projectionCols.begin();
|
||||
i != jobInfo.projectionCols.end();
|
||||
i++)
|
||||
{
|
||||
SimpleColumn* sc = dynamic_cast<SimpleColumn*>(i->get());
|
||||
|
||||
if (sc != NULL)
|
||||
{
|
||||
if (sc->schemaName().empty())
|
||||
sc->oid(joblist::tableOid(sc, jobInfo.csc) + 1 + sc->colPosition());
|
||||
|
||||
scProjected.insert(UniqId(sc));
|
||||
}
|
||||
}
|
||||
|
||||
for (vector<SimpleColumn*>::const_iterator i = scs.begin(); i != scs.end(); i++)
|
||||
{
|
||||
if (scProjected.find(UniqId(*i)) == scProjected.end())
|
||||
{
|
||||
jobInfo.windowDels.push_back(SRCP((*i)->clone()));
|
||||
// MCOL-3343 Enable this if we decide to allow Window Functions to run with
|
||||
// aggregates with no group by. MariaDB allows this. Nobody else in the world does.
|
||||
// There will be more work to get it to function if we try this.
|
||||
// jobInfo.windowSet.insert(getTupleKey(jobInfo, *i, true));
|
||||
scProjected.insert(UniqId(*i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo)
|
||||
{
|
||||
// window functions in select clause, selected or in expression
|
||||
@@ -404,6 +439,23 @@ void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, J
|
||||
if (jobInfo.windowCols.empty())
|
||||
return;
|
||||
|
||||
// Add in the non-window side of arithmetic columns and functions
|
||||
for (uint64_t i = 0; i < jobInfo.windowExps.size(); i++)
|
||||
{
|
||||
const ArithmeticColumn* ac =
|
||||
dynamic_cast<const ArithmeticColumn*>(jobInfo.windowExps[i].get());
|
||||
const FunctionColumn* fc =
|
||||
dynamic_cast<const FunctionColumn*>(jobInfo.windowExps[i].get());
|
||||
|
||||
if (ac != NULL && ac->windowfunctionColumnList().size() > 0)
|
||||
{
|
||||
AddSimplColumn(ac->simpleColumnList(), jobInfo);
|
||||
}
|
||||
else if (fc != NULL && fc->windowfunctionColumnList().size() > 0)
|
||||
{
|
||||
AddSimplColumn(fc->simpleColumnList(), jobInfo);
|
||||
}
|
||||
}
|
||||
// reconstruct the delivered column list with auxiliary columns
|
||||
set<uint64_t> colSet;
|
||||
jobInfo.deliveredCols.resize(0);
|
||||
@@ -445,7 +497,13 @@ void WindowFunctionStep::checkWindowFunction(CalpontSelectExecutionPlan* csep, J
|
||||
key = getTupleKey(jobInfo, *j, true);
|
||||
|
||||
if (colSet.find(key) == colSet.end())
|
||||
{
|
||||
jobInfo.deliveredCols.push_back(*j);
|
||||
// MCOL-3343 Enable this if we decide to allow Window Functions to run with
|
||||
// aggregates with no group by. MariaDB allows this. Nobody else in the world does.
|
||||
// There will be more work to get it to function if we try this.
|
||||
// jobInfo.windowSet.insert(getTupleKey(jobInfo, *j, true));
|
||||
}
|
||||
|
||||
colSet.insert(key);
|
||||
}
|
||||
|
@@ -148,6 +148,8 @@ private:
|
||||
void formatMiniStats();
|
||||
void printCalTrace();
|
||||
|
||||
static void AddSimplColumn(const std::vector<execplan::SimpleColumn*>& scs, JobInfo& jobInfo);
|
||||
|
||||
class Runner
|
||||
{
|
||||
public:
|
||||
|
@@ -101,7 +101,7 @@ END //
|
||||
create procedure columnstore_upgrade()
|
||||
`columnstore_upgrade`: BEGIN
|
||||
DECLARE done INTEGER DEFAULT 0;
|
||||
DECLARE schema_table VARCHAR(100) DEFAULT "";
|
||||
DECLARE schema_table VARCHAR(100) CHARACTER SET utf8 DEFAULT "";
|
||||
DECLARE table_list CURSOR FOR select concat('`', table_schema,'`.`',table_name,'`') from information_schema.tables where engine='columnstore';
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
|
||||
OPEN table_list;
|
||||
@@ -115,6 +115,5 @@ create procedure columnstore_upgrade()
|
||||
DEALLOCATE PREPARE stmt;
|
||||
END LOOP;
|
||||
END //
|
||||
delimiter ;
|
||||
|
||||
DELIMITER ;
|
||||
|
@@ -1043,7 +1043,6 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
|
||||
dataLength = *(uint16_t*) buf;
|
||||
buf = buf + 2 ;
|
||||
}
|
||||
|
||||
escape.assign((char*)buf, dataLength);
|
||||
boost::replace_all(escape, "\\", "\\\\");
|
||||
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter);
|
||||
@@ -1061,22 +1060,16 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
|
||||
buf = buf + 2 ;
|
||||
}
|
||||
|
||||
if ( dataLength > ci.columnTypes[colpos].colWidth)
|
||||
dataLength = ci.columnTypes[colpos].colWidth;
|
||||
|
||||
escape.assign((char*)buf, dataLength);
|
||||
boost::replace_all(escape, "\\", "\\\\");
|
||||
|
||||
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter);
|
||||
}
|
||||
}
|
||||
|
||||
//buf += ci.columnTypes[colpos].colWidth;
|
||||
if (ci.utf8)
|
||||
buf += (ci.columnTypes[colpos].colWidth * 3);
|
||||
else
|
||||
buf += ci.columnTypes[colpos].colWidth;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -2363,8 +2363,15 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp)
|
||||
sc->colPosition(j);
|
||||
string tableAlias(csep->derivedTbAlias());
|
||||
sc->tableAlias(lower(tableAlias));
|
||||
sc->viewName(lower(viewName));
|
||||
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
|
||||
if (!viewName.empty())
|
||||
{
|
||||
sc->viewName(viewName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sc->viewName(csep->derivedTbView());
|
||||
}
|
||||
sc->resultType(cols[j]->resultType());
|
||||
sc->hasAggregate(cols[j]->hasAggregate());
|
||||
|
||||
|
@@ -1340,16 +1340,13 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
||||
else
|
||||
schemaName = string(item->db_name);
|
||||
|
||||
columnAssignmentPtr = new ColumnAssignment(item->name.str, "=", "");
|
||||
if (item->field_type() == MYSQL_TYPE_TIMESTAMP ||
|
||||
item->field_type() == MYSQL_TYPE_TIMESTAMP2)
|
||||
{
|
||||
timeStampColumnNames.insert(string(item->name.str));
|
||||
}
|
||||
|
||||
columnAssignmentPtr = new ColumnAssignment();
|
||||
columnAssignmentPtr->fColumn = string(item->name.str);
|
||||
columnAssignmentPtr->fOperator = "=";
|
||||
columnAssignmentPtr->fFuncScale = 0;
|
||||
Item* value = value_it++;
|
||||
|
||||
if (value->type() == Item::CONST_ITEM)
|
||||
@@ -1468,8 +1465,9 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
||||
else if ( value->type() == Item::NULL_ITEM )
|
||||
{
|
||||
// dmlStmt += "NULL";
|
||||
columnAssignmentPtr->fScalarExpression = "NULL";
|
||||
columnAssignmentPtr->fScalarExpression = "";
|
||||
columnAssignmentPtr->fFromCol = false;
|
||||
columnAssignmentPtr->fIsNull = true;
|
||||
}
|
||||
else if ( value->type() == Item::SUBSELECT_ITEM )
|
||||
{
|
||||
@@ -1535,11 +1533,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
||||
{
|
||||
if (timeStampColumnNames.find(onUpdateTimeStampColumns[i]) == timeStampColumnNames.end())
|
||||
{
|
||||
columnAssignmentPtr = new ColumnAssignment();
|
||||
columnAssignmentPtr->fColumn = string(onUpdateTimeStampColumns[i]);
|
||||
columnAssignmentPtr->fOperator = "=";
|
||||
columnAssignmentPtr->fFuncScale = 0;
|
||||
columnAssignmentPtr->fFromCol = false;
|
||||
columnAssignmentPtr = new ColumnAssignment(string(onUpdateTimeStampColumns[i]), "=", "");
|
||||
struct timeval tv;
|
||||
char buf[64];
|
||||
gettimeofday(&tv, 0);
|
||||
|
@@ -347,6 +347,7 @@ SCSEP FromSubQuery::transform()
|
||||
gwi.subQuery = this;
|
||||
gwi.viewName = fGwip.viewName;
|
||||
csep->derivedTbAlias(fAlias); // always lower case
|
||||
csep->derivedTbView(fGwip.viewName.alias);
|
||||
|
||||
if (getSelectPlan(gwi, *fFromSub, csep, fPushdownHand) != 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user