You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-1052 WIP Incorporate a fix for MCOL-1348. Comment on the group_by_handler class.
This commit is contained in:
@ -1091,6 +1091,7 @@ void TupleAggregateStep::prep1PhaseAggregate(
|
||||
vector<SP_ROWAGG_FUNC_t> functionVec;
|
||||
uint32_t bigIntWidth = sizeof(int64_t);
|
||||
uint32_t bigUintWidth = sizeof(uint64_t);
|
||||
uint32_t projColsUDAFIndex = 0;
|
||||
|
||||
mcsv1sdk::mcsv1_UDAF* pUDAFFunc = NULL;
|
||||
// for count column of average function
|
||||
@ -1279,16 +1280,24 @@ void TupleAggregateStep::prep1PhaseAggregate(
|
||||
|
||||
if (aggOp == ROWAGG_UDAF)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.projectionCols[i].get());
|
||||
std::vector<SRCP>::iterator it = jobInfo.projectionCols.begin() + projColsUDAFIndex;
|
||||
for (; it != jobInfo.projectionCols.end(); it++)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>((*it).get());
|
||||
projColsUDAFIndex++;
|
||||
if (udafc)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, i));
|
||||
break;
|
||||
}
|
||||
|
||||
if (udafc)
|
||||
{
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, i));
|
||||
}
|
||||
else
|
||||
|
||||
if (it == jobInfo.projectionCols.end())
|
||||
{
|
||||
throw logic_error("prep1PhasesAggregate: A UDAF function is called but there's no UDAFColumn");
|
||||
throw logic_error("prep1PhaseAggregate: A UDAF function is called but there's no/not enough UDAFColumn/-s");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1649,6 +1658,7 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
AGG_MAP aggFuncMap;
|
||||
mcsv1sdk::mcsv1_UDAF* pUDAFFunc = NULL;
|
||||
set<uint32_t> avgSet;
|
||||
uint32_t projColsUDAFIndex = 0;
|
||||
|
||||
// for count column of average function
|
||||
map<uint32_t, SP_ROWAGG_FUNC_t> avgFuncMap, avgDistFuncMap;
|
||||
@ -1812,17 +1822,24 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
|
||||
|
||||
if (aggOp == ROWAGG_UDAF)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.projectionCols[i].get());
|
||||
std::vector<SRCP>::iterator it = jobInfo.projectionCols.begin() + projColsUDAFIndex;
|
||||
for (; it != jobInfo.projectionCols.end(); it++)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>((*it).get());
|
||||
projColsUDAFIndex++;
|
||||
if (udafc)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAgg));
|
||||
break;
|
||||
}
|
||||
|
||||
if (udafc)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAgg));
|
||||
}
|
||||
else
|
||||
|
||||
if (it == jobInfo.projectionCols.end())
|
||||
{
|
||||
throw logic_error("prep1PhaseDistinctAggregate: A UDAF function is called but there's no UDAFColumn");
|
||||
throw logic_error("prep1PhaseDistinctAggregate: A UDAF function is called but there's no/not enough UDAFColumn/-s");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2814,6 +2831,7 @@ void TupleAggregateStep::prep2PhasesAggregate(
|
||||
vector<pair<uint32_t, int> > aggColVec;
|
||||
set<uint32_t> avgSet;
|
||||
vector<std::pair<uint32_t, int> >& returnedColVec = jobInfo.returnedColVec;
|
||||
uint32_t projColsUDAFIndex = 0;
|
||||
|
||||
for (uint64_t i = 0; i < returnedColVec.size(); i++)
|
||||
{
|
||||
@ -2992,17 +3010,24 @@ void TupleAggregateStep::prep2PhasesAggregate(
|
||||
|
||||
if (aggOp == ROWAGG_UDAF)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.projectionCols[i].get());
|
||||
std::vector<SRCP>::iterator it = jobInfo.projectionCols.begin() + projColsUDAFIndex;
|
||||
for (; it != jobInfo.projectionCols.end(); it++)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>((*it).get());
|
||||
projColsUDAFIndex++;
|
||||
if (udafc)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAggPm));
|
||||
break;
|
||||
}
|
||||
|
||||
if (udafc)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAggPm));
|
||||
}
|
||||
else
|
||||
|
||||
if (it == jobInfo.projectionCols.end())
|
||||
{
|
||||
throw logic_error("prep2PhasesAggregate: A UDAF function is called but there's no UDAFColumn");
|
||||
throw logic_error("prep2PhasesAggregate: A UDAF function is called but there's no/not enough UDAFColumn/-s");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -3583,6 +3608,7 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
vector<pair<uint32_t, int> > aggColVec, aggNoDistColVec;
|
||||
set<uint32_t> avgSet, avgDistSet;
|
||||
vector<std::pair<uint32_t, int> >& returnedColVec = jobInfo.returnedColVec;
|
||||
uint32_t projColsUDAFIndex = 0;
|
||||
|
||||
for (uint64_t i = 0; i < returnedColVec.size(); i++)
|
||||
{
|
||||
@ -3796,17 +3822,23 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
|
||||
|
||||
if (aggOp == ROWAGG_UDAF)
|
||||
{
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.projectionCols[i].get());
|
||||
|
||||
if (udafc)
|
||||
std::vector<SRCP>::iterator it = jobInfo.projectionCols.begin() + projColsUDAFIndex;
|
||||
for (; it != jobInfo.projectionCols.end(); it++)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAggPm));
|
||||
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>((*it).get());
|
||||
projColsUDAFIndex++;
|
||||
if (udafc)
|
||||
{
|
||||
pUDAFFunc = udafc->getContext().getFunction();
|
||||
// Create a RowAggFunctionCol (UDAF subtype) with the context.
|
||||
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAggPm));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (it == jobInfo.projectionCols.end())
|
||||
{
|
||||
throw logic_error("prep2PhasesDistinctAggregate: A UDAF function is called but there's no UDAFColumn");
|
||||
throw logic_error("prep2PhasesDistinctAggregate: A UDAF function is called but there's no/not enough UDAFColumn/-s");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -248,6 +248,30 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/*@brief group_by_handler class*/
|
||||
/***********************************************************
|
||||
* DESCRIPTION:
|
||||
* Provides server with group_by_handler API methods.
|
||||
* One should read comments in server/sql/group_by_handler.h
|
||||
* Attributes:
|
||||
* select - attribute contains all GROUP BY, HAVING, ORDER items and calls it
|
||||
* an extended SELECT list accordin to comments in
|
||||
* server/sql/group_handler.cc.
|
||||
* So the temporary table for
|
||||
* select count(*) from b group by a having a > 3 order by a
|
||||
* will have 4 columns not 1.
|
||||
* However server ignores all NULLs used in GROUP BY, HAVING, ORDER.
|
||||
* table_list - contains all tables involved. Must be CS tables only.
|
||||
* distinct - looks like a useless thing for now. Couldn't get it set by server.
|
||||
* where - where items.
|
||||
* group_by - group by ORDER items.
|
||||
* order_by - order by ORDER items.
|
||||
* having - having Item.
|
||||
* Methods:
|
||||
* init_scan - get plan and send it to ExeMgr. Get the execution result.
|
||||
* next_row - get a row back from sm.
|
||||
* end_scan - finish and clean the things up.
|
||||
***********************************************************/
|
||||
class ha_calpont_group_by_handler: public group_by_handler
|
||||
{
|
||||
public:
|
||||
@ -265,6 +289,7 @@ class ha_calpont_group_by_handler: public group_by_handler
|
||||
int init_scan();
|
||||
int next_row();
|
||||
int end_scan();
|
||||
|
||||
List<Item> *select;
|
||||
TABLE_LIST *table_list;
|
||||
bool distinct;
|
||||
|
@ -5103,9 +5103,10 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
||||
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR)
|
||||
return ER_INTERNAL_ERROR;
|
||||
|
||||
// MCOL-1052
|
||||
// by pass the extra union trips. return 0
|
||||
if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE)
|
||||
return 0;
|
||||
//if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE)
|
||||
// return 0;
|
||||
|
||||
// @bug 2232. Basic SP support. Error out non support sp cases.
|
||||
// @bug 3939. Only error out for sp with select. Let pass for alter table in sp.
|
||||
@ -5689,6 +5690,7 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
|
||||
if (thd->infinidb_vtable.cal_conn_info)
|
||||
ci = reinterpret_cast<cal_connection_info*>(thd->infinidb_vtable.cal_conn_info);
|
||||
|
||||
// MCOL-1052
|
||||
//if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY )
|
||||
//{
|
||||
// thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE;// flip back to normal state
|
||||
|
@ -513,6 +513,18 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
|
||||
Item* orderItem = *(orderCol->item);
|
||||
srcp.reset(buildReturnedColumn(orderItem, gwi, nonSupport));
|
||||
|
||||
// MCOL-1052 GROUP BY handler has all of query's agg Items
|
||||
// as field and correlates them with its extended SELECT Items.
|
||||
if (!srcp)
|
||||
{
|
||||
orderItem = orderCol->item_ptr;
|
||||
if (orderItem)
|
||||
{
|
||||
gwi.fatalParseError = false;
|
||||
srcp.reset(buildReturnedColumn(orderItem, gwi, nonSupport));
|
||||
}
|
||||
}
|
||||
|
||||
if (!srcp)
|
||||
return nullOnError(gwi);
|
||||
|
||||
|
Reference in New Issue
Block a user