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
clang format apply
This commit is contained in:
@ -22,9 +22,9 @@ using namespace std;
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include<sstream>
|
||||
#include<exception>
|
||||
#include<iostream>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "messagequeue.h"
|
||||
@ -47,27 +47,26 @@ using namespace execplan;
|
||||
|
||||
class TPCH_EXECPLAN : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TPCH_EXECPLAN);
|
||||
|
||||
CPPUNIT_TEST_SUITE( TPCH_EXECPLAN );
|
||||
CPPUNIT_TEST(Q1);
|
||||
|
||||
CPPUNIT_TEST( Q1 );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
public:
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void Q1()
|
||||
{
|
||||
string sql = "\
|
||||
void Q1()
|
||||
{
|
||||
string sql =
|
||||
"\
|
||||
select\
|
||||
nation,\
|
||||
o_year,\
|
||||
@ -101,141 +100,130 @@ order by\
|
||||
nation,\
|
||||
o_year desc;";
|
||||
|
||||
CalpontSelectExecutionPlan csep;
|
||||
CalpontSelectExecutionPlan csep;
|
||||
|
||||
// Returned columns
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList;
|
||||
// Returned columns
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList returnedColumnList;
|
||||
|
||||
// these columns are from the temp table of FROM clause.
|
||||
// I hereby give schema name "calpont", table name "FROMTABLE",
|
||||
SimpleColumn* c1 = new SimpleColumn("tpch.nation.n_name");
|
||||
c1->tableAlias("profit");
|
||||
c1->alias("nation");
|
||||
returnedColumnList.push_back(c1);
|
||||
ArithmeticColumn* c2 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
|
||||
c2->tableAlias("profit");
|
||||
c2->tableAlias("o_year");
|
||||
returnedColumnList.push_back(c2);
|
||||
ArithmeticColumn* c3 = new ArithmeticColumn("sum(amount)");
|
||||
c3->alias("sum_profit");
|
||||
returnedColumnList.push_back(c3);
|
||||
// these columns are from the temp table of FROM clause.
|
||||
// I hereby give schema name "calpont", table name "FROMTABLE",
|
||||
SimpleColumn* c1 = new SimpleColumn("tpch.nation.n_name");
|
||||
c1->tableAlias("profit");
|
||||
c1->alias("nation");
|
||||
returnedColumnList.push_back(c1);
|
||||
ArithmeticColumn* c2 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
|
||||
c2->tableAlias("profit");
|
||||
c2->tableAlias("o_year");
|
||||
returnedColumnList.push_back(c2);
|
||||
ArithmeticColumn* c3 = new ArithmeticColumn("sum(amount)");
|
||||
c3->alias("sum_profit");
|
||||
returnedColumnList.push_back(c3);
|
||||
|
||||
csep.returnedCols(returnedColumnList);
|
||||
csep.returnedCols(returnedColumnList);
|
||||
|
||||
// subselect in FROM clause
|
||||
CalpontSelectExecutionPlan* subsep =
|
||||
new CalpontSelectExecutionPlan(CalpontSelectExecutionPlan::FROM);
|
||||
// subselect in FROM clause
|
||||
CalpontSelectExecutionPlan* subsep = new CalpontSelectExecutionPlan(CalpontSelectExecutionPlan::FROM);
|
||||
|
||||
// subselect returned columns
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subReturnedColList;
|
||||
SimpleColumn* sc1 = new SimpleColumn("tpch.nation.n_name");
|
||||
sc1->alias("nation");
|
||||
sc1->tableAlias("profit");
|
||||
subReturnedColList.push_back(sc1);
|
||||
// subselect returned columns
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subReturnedColList;
|
||||
SimpleColumn* sc1 = new SimpleColumn("tpch.nation.n_name");
|
||||
sc1->alias("nation");
|
||||
sc1->tableAlias("profit");
|
||||
subReturnedColList.push_back(sc1);
|
||||
|
||||
ArithmeticColumn* sc2 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
|
||||
sc2->alias ("o_year");
|
||||
sc2->tableAlias("profit");
|
||||
subReturnedColList.push_back(sc2);
|
||||
ArithmeticColumn* sc2 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
|
||||
sc2->alias("o_year");
|
||||
sc2->tableAlias("profit");
|
||||
subReturnedColList.push_back(sc2);
|
||||
|
||||
ArithmeticColumn* sc3 = new ArithmeticColumn(
|
||||
"tpch.lineitem.l_extendeprice * (1-tpch.lineitem.l_discount)- tpch.partsupp.ps_supplycost * tpch.lineitem.l_quantity");
|
||||
sc3->alias("amount");
|
||||
sc3->tableAlias("shipping");
|
||||
subReturnedColList.push_back(sc3);
|
||||
ArithmeticColumn* sc3 = new ArithmeticColumn(
|
||||
"tpch.lineitem.l_extendeprice * (1-tpch.lineitem.l_discount)- tpch.partsupp.ps_supplycost * "
|
||||
"tpch.lineitem.l_quantity");
|
||||
sc3->alias("amount");
|
||||
sc3->tableAlias("shipping");
|
||||
subReturnedColList.push_back(sc3);
|
||||
|
||||
subsep->returnedCols(subReturnedColList);
|
||||
subsep->returnedCols(subReturnedColList);
|
||||
|
||||
// subselect filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subFilterTokenList;
|
||||
// subselect filters
|
||||
CalpontSelectExecutionPlan::FilterTokenList subFilterTokenList;
|
||||
|
||||
SimpleFilter* sf1 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.supplier.s_suppkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_suppkey"));
|
||||
subFilterTokenList.push_back(sf1);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf1 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.supplier.s_suppkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_suppkey"));
|
||||
subFilterTokenList.push_back(sf1);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf2 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.partsupp.ps_suppkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_suppkey"));
|
||||
subFilterTokenList.push_back(sf2);
|
||||
SimpleFilter* sf2 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.partsupp.ps_suppkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_suppkey"));
|
||||
subFilterTokenList.push_back(sf2);
|
||||
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf3 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.partsupp.ps_partkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_partkey"));
|
||||
subFilterTokenList.push_back(sf3);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf3 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.partsupp.ps_partkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_partkey"));
|
||||
subFilterTokenList.push_back(sf3);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf4 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.part.p_partkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_partkey"));
|
||||
subFilterTokenList.push_back(sf4);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf4 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.part.p_partkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_partkey"));
|
||||
subFilterTokenList.push_back(sf4);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf5 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.order.o_orderkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_orderkey"));
|
||||
subFilterTokenList.push_back(sf5);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf5 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.order.o_orderkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_orderkey"));
|
||||
subFilterTokenList.push_back(sf5);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf6 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.supplier.s_nationkey"),
|
||||
new SimpleColumn("tpch.nation.n_nationkey"));
|
||||
subFilterTokenList.push_back(sf6);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf6 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.supplier.s_nationkey"),
|
||||
new SimpleColumn("tpch.nation.n_nationkey"));
|
||||
subFilterTokenList.push_back(sf6);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf7 = new SimpleFilter ( new Operator("like"),
|
||||
new SimpleColumn("tpch.part.p_name"),
|
||||
new ConstantColumn ("%:1%"));
|
||||
subFilterTokenList.push_back(sf7);
|
||||
SimpleFilter* sf7 = new SimpleFilter(new Operator("like"), new SimpleColumn("tpch.part.p_name"),
|
||||
new ConstantColumn("%:1%"));
|
||||
subFilterTokenList.push_back(sf7);
|
||||
|
||||
subsep->filterTokenList(subFilterTokenList);
|
||||
subsep->tableAlias("profit");
|
||||
subsep->filterTokenList(subFilterTokenList);
|
||||
subsep->tableAlias("profit");
|
||||
|
||||
CalpontSelectExecutionPlan::SelectList fromSubSelectList;
|
||||
fromSubSelectList.push_back(subsep);
|
||||
csep.subSelects(fromSubSelectList);
|
||||
CalpontSelectExecutionPlan::SelectList fromSubSelectList;
|
||||
fromSubSelectList.push_back(subsep);
|
||||
csep.subSelects(fromSubSelectList);
|
||||
|
||||
ParseTree* pt = const_cast<ParseTree*>(subsep->filters());
|
||||
pt->drawTree("q9.dot");
|
||||
ParseTree* pt = const_cast<ParseTree*>(subsep->filters());
|
||||
pt->drawTree("q9.dot");
|
||||
|
||||
// Group by
|
||||
CalpontSelectExecutionPlan::GroupByColumnList groupByList;
|
||||
SimpleColumn* g1 = new SimpleColumn (*c1);
|
||||
groupByList.push_back (g1);
|
||||
//ArithmeticColumn *g2 = new ArithmeticColumn (*c2);
|
||||
groupByList.push_back (c2->clone());
|
||||
csep.groupByCols(groupByList);
|
||||
|
||||
// Order by
|
||||
CalpontSelectExecutionPlan::OrderByColumnList orderByList;
|
||||
SimpleColumn* o1 = new SimpleColumn(*c1);
|
||||
orderByList.push_back(o1);
|
||||
ArithmeticColumn* o2 = c2->clone();
|
||||
o2->asc(false);
|
||||
orderByList.push_back(o2);
|
||||
csep.orderByCols(orderByList);
|
||||
|
||||
cout << csep;
|
||||
}
|
||||
// Group by
|
||||
CalpontSelectExecutionPlan::GroupByColumnList groupByList;
|
||||
SimpleColumn* g1 = new SimpleColumn(*c1);
|
||||
groupByList.push_back(g1);
|
||||
// ArithmeticColumn *g2 = new ArithmeticColumn (*c2);
|
||||
groupByList.push_back(c2->clone());
|
||||
csep.groupByCols(groupByList);
|
||||
|
||||
// Order by
|
||||
CalpontSelectExecutionPlan::OrderByColumnList orderByList;
|
||||
SimpleColumn* o1 = new SimpleColumn(*c1);
|
||||
orderByList.push_back(o1);
|
||||
ArithmeticColumn* o2 = c2->clone();
|
||||
o2->asc(false);
|
||||
orderByList.push_back(o2);
|
||||
csep.orderByCols(orderByList);
|
||||
|
||||
cout << csep;
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( TPCH_EXECPLAN );
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TPCH_EXECPLAN);
|
||||
|
||||
#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& registry = 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