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
Reformat all code to coding standard
This commit is contained in:
@ -48,91 +48,103 @@ extern "C" void init_demangler(int, int, int);
|
||||
|
||||
using namespace execplan;
|
||||
|
||||
class ExecPlanTest : public CppUnit::TestFixture {
|
||||
class ExecPlanTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( ExecPlanTest );
|
||||
CPPUNIT_TEST_SUITE( ExecPlanTest );
|
||||
|
||||
CPPUNIT_TEST( selectExecutionPlan_18 );
|
||||
CPPUNIT_TEST( selectExecutionPlan_18 );
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
static void walkfnString(const ParseTree* n)
|
||||
{
|
||||
char *r;
|
||||
static bool is_init = false;
|
||||
const char* mname = typeid(*(n->data())).name();
|
||||
if (!is_init)
|
||||
{
|
||||
::init_demangler(0, 0, 0);
|
||||
is_init = true;
|
||||
}
|
||||
r = ::cplus_demangle_with_style(mname, 7, 27);
|
||||
if (r != 0)
|
||||
{
|
||||
//cout << "mangle: " << mname << " demangle: " << r << endl;
|
||||
::free(r);
|
||||
}
|
||||
if (typeid(*(n->data())) == typeid(SimpleFilter))
|
||||
{
|
||||
cout << "SimpleFilter: " << endl;
|
||||
const SimpleFilter* sf = dynamic_cast<SimpleFilter*>(n->data());
|
||||
const ReturnedColumn* lhs = sf->lhs();
|
||||
const ReturnedColumn* rhs = sf->rhs();
|
||||
const Operator* op = sf->op();
|
||||
cout << '\t' << lhs->data() << ' ' << op->data() << ' ' << rhs->data();
|
||||
cout << endl << "\t\t";
|
||||
if (typeid(*lhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else if (typeid(*lhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << lhs->data() << " / ";
|
||||
}
|
||||
cout << "Operator: " << op->data() << " / ";
|
||||
if (typeid(*rhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << rhs->data();
|
||||
}
|
||||
else if (typeid(*rhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << rhs->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << rhs->data();
|
||||
}
|
||||
}
|
||||
else if (typeid(*(n->data())) == typeid(Operator))
|
||||
{
|
||||
cout << "Operator: ";
|
||||
const Operator* op = dynamic_cast<Operator*>(n->data());
|
||||
cout << '\t' << op->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << mname << " -x-: ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
static void walkfnString(const ParseTree* n)
|
||||
{
|
||||
char* r;
|
||||
static bool is_init = false;
|
||||
const char* mname = typeid(*(n->data())).name();
|
||||
|
||||
void setUp() {
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
}
|
||||
|
||||
void selectExecutionPlan_18() {
|
||||
if (!is_init)
|
||||
{
|
||||
::init_demangler(0, 0, 0);
|
||||
is_init = true;
|
||||
}
|
||||
|
||||
cout <<
|
||||
"SQL: \
|
||||
r = ::cplus_demangle_with_style(mname, 7, 27);
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
//cout << "mangle: " << mname << " demangle: " << r << endl;
|
||||
::free(r);
|
||||
}
|
||||
|
||||
if (typeid(*(n->data())) == typeid(SimpleFilter))
|
||||
{
|
||||
cout << "SimpleFilter: " << endl;
|
||||
const SimpleFilter* sf = dynamic_cast<SimpleFilter*>(n->data());
|
||||
const ReturnedColumn* lhs = sf->lhs();
|
||||
const ReturnedColumn* rhs = sf->rhs();
|
||||
const Operator* op = sf->op();
|
||||
cout << '\t' << lhs->data() << ' ' << op->data() << ' ' << rhs->data();
|
||||
cout << endl << "\t\t";
|
||||
|
||||
if (typeid(*lhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else if (typeid(*lhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << lhs->data() << " / ";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << lhs->data() << " / ";
|
||||
}
|
||||
|
||||
cout << "Operator: " << op->data() << " / ";
|
||||
|
||||
if (typeid(*rhs) == typeid(SimpleColumn))
|
||||
{
|
||||
cout << "SimpleColumn: " << rhs->data();
|
||||
}
|
||||
else if (typeid(*rhs) == typeid(ConstantColumn))
|
||||
{
|
||||
cout << "ConstantColumn: " << rhs->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "UNK: " << rhs->data();
|
||||
}
|
||||
}
|
||||
else if (typeid(*(n->data())) == typeid(Operator))
|
||||
{
|
||||
cout << "Operator: ";
|
||||
const Operator* op = dynamic_cast<Operator*>(n->data());
|
||||
cout << '\t' << op->data();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << mname << " -x-: ";
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void selectExecutionPlan_18()
|
||||
{
|
||||
|
||||
cout <<
|
||||
"SQL: \
|
||||
select \
|
||||
c_name, \
|
||||
c_custkey, \
|
||||
@ -164,146 +176,146 @@ group by \
|
||||
o_totalprice \
|
||||
order by \
|
||||
o_totalprice desc, \
|
||||
o_orderdate;"
|
||||
<< endl;
|
||||
o_orderdate;"
|
||||
<< endl;
|
||||
|
||||
// ****
|
||||
// **** THIS QUERY IS MISSING THE HAVING CLAUSE ON THE GROUP BY ****
|
||||
// **** THIS QUERY IS MISSING THE HAVING CLAUSE ON THE GROUP BY ****
|
||||
// ****
|
||||
|
||||
//This is the main query body for query 18
|
||||
CalpontSelectExecutionPlan *csep = new CalpontSelectExecutionPlan();
|
||||
|
||||
//This is the main query body for query 18
|
||||
CalpontSelectExecutionPlan* csep = new CalpontSelectExecutionPlan();
|
||||
|
||||
// Create the Projection (returned columns)
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList colList;
|
||||
SimpleColumn *c1 = new SimpleColumn("tpch.customer.c_name");
|
||||
SimpleColumn* c1 = new SimpleColumn("tpch.customer.c_name");
|
||||
colList.push_back(c1);
|
||||
SimpleColumn *c2 = new SimpleColumn("tpch.customer.c_custkey");
|
||||
SimpleColumn* c2 = new SimpleColumn("tpch.customer.c_custkey");
|
||||
colList.push_back(c2);
|
||||
SimpleColumn *c3 = new SimpleColumn("tpch.orders.o_orderkey");
|
||||
SimpleColumn* c3 = new SimpleColumn("tpch.orders.o_orderkey");
|
||||
colList.push_back(c3);
|
||||
SimpleColumn *c4 = new SimpleColumn("tpch.orders.o_orderdate");
|
||||
SimpleColumn* c4 = new SimpleColumn("tpch.orders.o_orderdate");
|
||||
colList.push_back(c4);
|
||||
SimpleColumn *c5 = new SimpleColumn("tpch.orders.o_totalprice");
|
||||
SimpleColumn* c5 = new SimpleColumn("tpch.orders.o_totalprice");
|
||||
colList.push_back(c5);
|
||||
ArithmeticColumn *c6 = new ArithmeticColumn("sum(l_quantity)");
|
||||
ArithmeticColumn* c6 = new ArithmeticColumn("sum(l_quantity)");
|
||||
colList.push_back(c6);
|
||||
|
||||
|
||||
csep->returnedCols(colList); // set Projection columns
|
||||
|
||||
// Filter columns
|
||||
CalpontSelectExecutionPlan::FilterTokenList csep_filterlist;
|
||||
|
||||
//Sub select filter
|
||||
CalpontSelectExecutionPlan *subcsep =
|
||||
CalpontSelectExecutionPlan::FilterTokenList csep_filterlist;
|
||||
|
||||
//Sub select filter
|
||||
CalpontSelectExecutionPlan* subcsep =
|
||||
new CalpontSelectExecutionPlan(CalpontSelectExecutionPlan::WHERE);
|
||||
|
||||
//subselect return column(s)
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subColList;
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subColList;
|
||||
|
||||
SimpleColumn *sc1 = new SimpleColumn ("tpch.lineitem.l_orderkey");
|
||||
subColList.push_back(sc1);
|
||||
// Append returned columns to subselect
|
||||
subcsep->returnedCols(subColList);
|
||||
SimpleColumn* sc1 = new SimpleColumn ("tpch.lineitem.l_orderkey");
|
||||
subColList.push_back(sc1);
|
||||
// Append returned columns to subselect
|
||||
subcsep->returnedCols(subColList);
|
||||
|
||||
//subselect Filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subcsep_filterlist;
|
||||
SimpleFilter *sf1 = new SimpleFilter ( new Operator("IN"),
|
||||
new SimpleColumn ("tpch.lineitem.??"),
|
||||
new ConstantColumn("%Customer%Complaints%"));
|
||||
subcsep_filterlist.push_back(sf1);
|
||||
//subselect Filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subcsep_filterlist;
|
||||
SimpleFilter* sf1 = new SimpleFilter ( new Operator("IN"),
|
||||
new SimpleColumn ("tpch.lineitem.??"),
|
||||
new ConstantColumn("%Customer%Complaints%"));
|
||||
subcsep_filterlist.push_back(sf1);
|
||||
|
||||
// Build subGroup By List
|
||||
// Build subGroup By List
|
||||
CalpontSelectExecutionPlan::GroupByColumnList subcsep_groupbyList;
|
||||
SimpleColumn *sg1 = new SimpleColumn ("tpch.lineitem.l_orderkey");
|
||||
SimpleColumn* sg1 = new SimpleColumn ("tpch.lineitem.l_orderkey");
|
||||
subcsep_groupbyList.push_back(sg1);
|
||||
subcsep->groupByCols(subcsep_groupbyList); //Set GroupBy columns
|
||||
subcsep->groupByCols(subcsep_groupbyList); //Set GroupBy columns
|
||||
|
||||
//subHaving Filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subcsep_havingList;
|
||||
|
||||
SimpleFilter *sh1 = new SimpleFilter ( new Operator(">"),
|
||||
new ArithmeticColumn("sum(l_quantity)"),
|
||||
new ConstantColumn(":1"));
|
||||
//subHaving Filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subcsep_havingList;
|
||||
|
||||
SimpleFilter* sh1 = new SimpleFilter ( new Operator(">"),
|
||||
new ArithmeticColumn("sum(l_quantity)"),
|
||||
new ConstantColumn(":1"));
|
||||
subcsep_havingList.push_back(sh1);
|
||||
subcsep->havingTokenList(subcsep_havingList); //Set GroupBy columns
|
||||
|
||||
//subcsep->filterTokenList(subcsep_havingList); //Set GroupBy columns
|
||||
/* --------------- sub select ends here ---------------- */
|
||||
|
||||
//CalpontSelectExecutionPlan::FilterTokenList subFilterTokenList;
|
||||
SelectFilter *f1 = new SelectFilter (new SimpleColumn ("tpch.orders.o_orderkey"),
|
||||
new Operator("IN"),
|
||||
subcsep);
|
||||
|
||||
csep_filterlist.push_back(f1);
|
||||
subcsep->havingTokenList(subcsep_havingList); //Set GroupBy columns
|
||||
|
||||
//subcsep->filterTokenList(subcsep_havingList); //Set GroupBy columns
|
||||
/* --------------- sub select ends here ---------------- */
|
||||
|
||||
//CalpontSelectExecutionPlan::FilterTokenList subFilterTokenList;
|
||||
SelectFilter* f1 = new SelectFilter (new SimpleColumn ("tpch.orders.o_orderkey"),
|
||||
new Operator("IN"),
|
||||
subcsep);
|
||||
|
||||
csep_filterlist.push_back(f1);
|
||||
|
||||
csep_filterlist.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter *f2 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn ("tpch.customer.c_custkey"),
|
||||
new SimpleColumn ("tpch.orders.o_custkey"));
|
||||
csep_filterlist.push_back(f2);
|
||||
SimpleFilter* f2 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn ("tpch.customer.c_custkey"),
|
||||
new SimpleColumn ("tpch.orders.o_custkey"));
|
||||
csep_filterlist.push_back(f2);
|
||||
|
||||
csep_filterlist.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter *f3 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn ("tpch.orders.o_orderkey"),
|
||||
new SimpleColumn ("tpch.lineitem.l_orderkey"));
|
||||
csep_filterlist.push_back(f3);
|
||||
|
||||
SimpleFilter* f3 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn ("tpch.orders.o_orderkey"),
|
||||
new SimpleColumn ("tpch.lineitem.l_orderkey"));
|
||||
csep_filterlist.push_back(f3);
|
||||
|
||||
csep->filterTokenList(csep_filterlist); //Set Filter Columns
|
||||
|
||||
|
||||
// Build Group By List
|
||||
// Build Group By List
|
||||
CalpontSelectExecutionPlan::GroupByColumnList csep_groupbyList;
|
||||
SimpleColumn *g1 = new SimpleColumn("tpch.customer.c_name");
|
||||
SimpleColumn* g1 = new SimpleColumn("tpch.customer.c_name");
|
||||
csep_groupbyList.push_back(g1);
|
||||
SimpleColumn *g2 = new SimpleColumn("tpch.customer.c_custkey");
|
||||
SimpleColumn* g2 = new SimpleColumn("tpch.customer.c_custkey");
|
||||
csep_groupbyList.push_back(g2);
|
||||
SimpleColumn *g3 = new SimpleColumn("tpch.orders.o_orderkey");
|
||||
SimpleColumn* g3 = new SimpleColumn("tpch.orders.o_orderkey");
|
||||
csep_groupbyList.push_back(g3);
|
||||
SimpleColumn *g4 = new SimpleColumn("tpch.orders.o_orderdate");
|
||||
SimpleColumn* g4 = new SimpleColumn("tpch.orders.o_orderdate");
|
||||
csep_groupbyList.push_back(g4);
|
||||
SimpleColumn *g5 = new SimpleColumn("tpch.orders.o_totalprice");
|
||||
SimpleColumn* g5 = new SimpleColumn("tpch.orders.o_totalprice");
|
||||
csep_groupbyList.push_back(g5);
|
||||
csep->groupByCols(csep_groupbyList); //Set GroupBy columns
|
||||
csep->groupByCols(csep_groupbyList); //Set GroupBy columns
|
||||
|
||||
// Order By List
|
||||
// Order By List
|
||||
CalpontSelectExecutionPlan::OrderByColumnList csep_orderbyList;
|
||||
SimpleColumn *o1 = new SimpleColumn("tpch.orders.o_totalprice");
|
||||
SimpleColumn* o1 = new SimpleColumn("tpch.orders.o_totalprice");
|
||||
o1->asc(false);
|
||||
csep_orderbyList.push_back(o1);
|
||||
SimpleColumn *o2 = new SimpleColumn("tpch.orders.o_orderdate");
|
||||
SimpleColumn* o2 = new SimpleColumn("tpch.orders.o_orderdate");
|
||||
csep_orderbyList.push_back(o2);
|
||||
csep->orderByCols(csep_orderbyList); //Set OrderBy columns
|
||||
|
||||
//filterList->walk(walkfnString); ??
|
||||
csep->orderByCols(csep_orderbyList); //Set OrderBy columns
|
||||
|
||||
// Print the parse tree
|
||||
ParseTree *pt = const_cast<ParseTree*>(csep->filters());
|
||||
//filterList->walk(walkfnString); ??
|
||||
|
||||
// Print the parse tree
|
||||
ParseTree* pt = const_cast<ParseTree*>(csep->filters());
|
||||
pt->drawTree("selectExecutionPlan_18.dot");
|
||||
|
||||
cout << "\nCalpont Execution Plan:" << endl;
|
||||
cout << *csep << endl;
|
||||
cout << " --- end of test 18 ---" << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ExecPlanTest );
|
||||
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user