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
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\
|
||||
o_year,\
|
||||
sum(decode(nation, ':1', volumn, 0)) / sum(volume) as mkt_share\
|
||||
@ -103,161 +102,148 @@ group by\
|
||||
order by\
|
||||
o_year;";
|
||||
|
||||
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("calpont.FROMTABLE.o_year");
|
||||
returnedColumnList.push_back(c1);
|
||||
ArithmeticColumn* c2 = new ArithmeticColumn("sum(decode(calpont.FROMTABLE.nation, ':1', calpont.FROMTABLE.volumn, 0))/sum(tpch.FROMTABLE.volumn)");
|
||||
returnedColumnList.push_back(c2);
|
||||
// these columns are from the temp table of FROM clause.
|
||||
// I hereby give schema name "calpont", table name "FROMTABLE",
|
||||
SimpleColumn* c1 = new SimpleColumn("calpont.FROMTABLE.o_year");
|
||||
returnedColumnList.push_back(c1);
|
||||
ArithmeticColumn* c2 = new ArithmeticColumn(
|
||||
"sum(decode(calpont.FROMTABLE.nation, ':1', calpont.FROMTABLE.volumn, "
|
||||
"0))/sum(tpch.FROMTABLE.volumn)");
|
||||
returnedColumnList.push_back(c2);
|
||||
|
||||
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;
|
||||
ArithmeticColumn* sc1 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
|
||||
sc1->alias ("o_year");
|
||||
subReturnedColList.push_back(sc1);
|
||||
// subselect returned columns
|
||||
CalpontSelectExecutionPlan::ReturnedColumnList subReturnedColList;
|
||||
ArithmeticColumn* sc1 = new ArithmeticColumn("extract(year from tpch.orders.o_orderdate)");
|
||||
sc1->alias("o_year");
|
||||
subReturnedColList.push_back(sc1);
|
||||
|
||||
ArithmeticColumn* sc2 = new ArithmeticColumn("tpch.lineitem.l_extendeprice * (1-tpch.lineitem.l_discount)");
|
||||
sc2->alias("volume");
|
||||
subReturnedColList.push_back(sc2);
|
||||
ArithmeticColumn* sc2 =
|
||||
new ArithmeticColumn("tpch.lineitem.l_extendeprice * (1-tpch.lineitem.l_discount)");
|
||||
sc2->alias("volume");
|
||||
subReturnedColList.push_back(sc2);
|
||||
|
||||
SimpleColumn* sc3 = new SimpleColumn("tpch.nation.n_name");
|
||||
sc3->tableAlias("n2");
|
||||
subReturnedColList.push_back(sc3);
|
||||
SimpleColumn* sc3 = new SimpleColumn("tpch.nation.n_name");
|
||||
sc3->tableAlias("n2");
|
||||
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.part.p_partkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_partkey"));
|
||||
subFilterTokenList.push_back(sf1);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf1 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.part.p_partkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_partkey"));
|
||||
subFilterTokenList.push_back(sf1);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf2 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.supplier.s_suppkey"),
|
||||
new SimpleColumn("tpch.lineitem.l_suppkey"));
|
||||
subFilterTokenList.push_back(sf2);
|
||||
SimpleFilter* sf2 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.supplier.s_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.lineitem.l_ordertkey"),
|
||||
new SimpleColumn("tpch.orders.o_orderkey"));
|
||||
subFilterTokenList.push_back(sf3);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf3 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.lineitem.l_ordertkey"),
|
||||
new SimpleColumn("tpch.orders.o_orderkey"));
|
||||
subFilterTokenList.push_back(sf3);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf4 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.orders.o_custkey"),
|
||||
new SimpleColumn("tpch.customer.c_custkey"));
|
||||
subFilterTokenList.push_back(sf4);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf4 = new SimpleFilter(new Operator("="), new SimpleColumn("tpch.orders.o_custkey"),
|
||||
new SimpleColumn("tpch.customer.c_custkey"));
|
||||
subFilterTokenList.push_back(sf4);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleColumn* n1_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
|
||||
n1_nationkey->tableAlias("n1");
|
||||
SimpleFilter* sf5 = new SimpleFilter (new Operator("="),
|
||||
new SimpleColumn("tpch.customer.c_nationkey"),
|
||||
n1_nationkey);
|
||||
subFilterTokenList.push_back(sf5);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleColumn* n1_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
|
||||
n1_nationkey->tableAlias("n1");
|
||||
SimpleFilter* sf5 =
|
||||
new SimpleFilter(new Operator("="), new SimpleColumn("tpch.customer.c_nationkey"), n1_nationkey);
|
||||
subFilterTokenList.push_back(sf5);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleColumn* n1_regionkey = new SimpleColumn("tpch.nation.n_regionkey");
|
||||
n1_regionkey->tableAlias ("n1");
|
||||
SimpleFilter* sf6 = new SimpleFilter ( new Operator("="),
|
||||
n1_regionkey,
|
||||
new SimpleColumn("tpch.region.r_regionkey"));
|
||||
subFilterTokenList.push_back(sf6);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleColumn* n1_regionkey = new SimpleColumn("tpch.nation.n_regionkey");
|
||||
n1_regionkey->tableAlias("n1");
|
||||
SimpleFilter* sf6 =
|
||||
new SimpleFilter(new Operator("="), n1_regionkey, new SimpleColumn("tpch.region.r_regionkey"));
|
||||
subFilterTokenList.push_back(sf6);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf7 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn("tpch.region.r_name"),
|
||||
new ConstantColumn (":2"));
|
||||
subFilterTokenList.push_back(sf7);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf7 =
|
||||
new SimpleFilter(new Operator("="), new SimpleColumn("tpch.region.r_name"), new ConstantColumn(":2"));
|
||||
subFilterTokenList.push_back(sf7);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleColumn* n2_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
|
||||
n2_nationkey->tableAlias("n2");
|
||||
SimpleFilter* sf9 = new SimpleFilter ( new Operator("="),
|
||||
new SimpleColumn("tpch.supplier.s_nationkey"),
|
||||
n2_nationkey);
|
||||
subFilterTokenList.push_back(sf9);
|
||||
SimpleColumn* n2_nationkey = new SimpleColumn("tpch.nation.n_nationkey");
|
||||
n2_nationkey->tableAlias("n2");
|
||||
SimpleFilter* sf9 =
|
||||
new SimpleFilter(new Operator("="), new SimpleColumn("tpch.supplier.s_nationkey"), n2_nationkey);
|
||||
subFilterTokenList.push_back(sf9);
|
||||
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
|
||||
SimpleFilter* sf10 = new SimpleFilter (new Operator (">="),
|
||||
new SimpleColumn ("tpch.orders.o_orderdate"),
|
||||
new ConstantColumn ("1995-01-01"));
|
||||
subFilterTokenList.push_back(sf10);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf11 = new SimpleFilter (new Operator ("<="),
|
||||
new SimpleColumn ("tpch.orders.o_orderdate"),
|
||||
new ConstantColumn ("1995-01-06"));
|
||||
subFilterTokenList.push_back(sf11);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf12 = new SimpleFilter (new Operator ("="),
|
||||
new SimpleColumn ("tpch.part.p_type"),
|
||||
new ConstantColumn ("3"));
|
||||
subFilterTokenList.push_back(sf12);
|
||||
SimpleFilter* sf10 = new SimpleFilter(new Operator(">="), new SimpleColumn("tpch.orders.o_orderdate"),
|
||||
new ConstantColumn("1995-01-01"));
|
||||
subFilterTokenList.push_back(sf10);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf11 = new SimpleFilter(new Operator("<="), new SimpleColumn("tpch.orders.o_orderdate"),
|
||||
new ConstantColumn("1995-01-06"));
|
||||
subFilterTokenList.push_back(sf11);
|
||||
subFilterTokenList.push_back(new Operator("and"));
|
||||
SimpleFilter* sf12 =
|
||||
new SimpleFilter(new Operator("="), new SimpleColumn("tpch.part.p_type"), new ConstantColumn("3"));
|
||||
subFilterTokenList.push_back(sf12);
|
||||
|
||||
subsep->filterTokenList(subFilterTokenList);
|
||||
subsep->tableAlias("all_nations");
|
||||
subsep->filterTokenList(subFilterTokenList);
|
||||
subsep->tableAlias("all_nations");
|
||||
|
||||
// end of subselect in FROM. push FROM subselect to selectList
|
||||
// NOTE: only FROM subselect needs to be pushed into selectList.
|
||||
// Subselects in WHERE or HAVING clause are in where or having
|
||||
// filter parse tree. It may make more sense to change the member
|
||||
// fSelectList of CSEP class to fFromSubSelect (type CSEP*)
|
||||
CalpontSelectExecutionPlan::SelectList fromSubSelectList;
|
||||
fromSubSelectList.push_back(subsep);
|
||||
csep.subSelects(fromSubSelectList);
|
||||
// end of subselect in FROM. push FROM subselect to selectList
|
||||
// NOTE: only FROM subselect needs to be pushed into selectList.
|
||||
// Subselects in WHERE or HAVING clause are in where or having
|
||||
// filter parse tree. It may make more sense to change the member
|
||||
// fSelectList of CSEP class to fFromSubSelect (type CSEP*)
|
||||
CalpontSelectExecutionPlan::SelectList fromSubSelectList;
|
||||
fromSubSelectList.push_back(subsep);
|
||||
csep.subSelects(fromSubSelectList);
|
||||
|
||||
ParseTree* pt = const_cast<ParseTree*>(subsep->filters());
|
||||
pt->drawTree("q8.dot");
|
||||
ParseTree* pt = const_cast<ParseTree*>(subsep->filters());
|
||||
pt->drawTree("q8.dot");
|
||||
|
||||
// Group by
|
||||
CalpontSelectExecutionPlan::GroupByColumnList groupByList;
|
||||
SimpleColumn* g1 = new SimpleColumn (*c1);
|
||||
groupByList.push_back (g1);
|
||||
// Group by
|
||||
CalpontSelectExecutionPlan::GroupByColumnList groupByList;
|
||||
SimpleColumn* g1 = new SimpleColumn(*c1);
|
||||
groupByList.push_back(g1);
|
||||
|
||||
csep.groupByCols(groupByList);
|
||||
csep.groupByCols(groupByList);
|
||||
|
||||
// Order by
|
||||
CalpontSelectExecutionPlan::OrderByColumnList orderByList;
|
||||
SimpleColumn* o1 = new SimpleColumn(*c1);
|
||||
orderByList.push_back(o1);
|
||||
|
||||
csep.orderByCols(orderByList);
|
||||
|
||||
cout << csep;
|
||||
}
|
||||
// Order by
|
||||
CalpontSelectExecutionPlan::OrderByColumnList orderByList;
|
||||
SimpleColumn* o1 = new SimpleColumn(*c1);
|
||||
orderByList.push_back(o1);
|
||||
|
||||
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