Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 0c33249

Browse files
committed
Add a test for 4 table join
1 parent 9b31dfe commit 0c33249

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/optimizer/binding.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ bool GroupExprBindingIterator::HasNext() {
173173
}
174174

175175
std::shared_ptr<OperatorExpression> GroupExprBindingIterator::Next() {
176-
LOG_DEBUG("Current_binding size :%lu", current_binding_->Children().size());
177176
return current_binding_;
178177
}
179178

src/optimizer/memo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GroupExpression *Memo::InsertExpression(std::shared_ptr<GroupExpression> gexpr,
3333
// If leaf, then just return
3434
if (gexpr->Op().GetType() == OpType::Leaf) {
3535
const LeafOperator *leaf = gexpr->Op().As<LeafOperator>();
36-
assert(target_group == UNDEFINED_GROUP ||
36+
PL_ASSERT(target_group == UNDEFINED_GROUP ||
3737
target_group == leaf->origin_group);
3838
gexpr->SetGroupID(leaf->origin_group);
3939
return nullptr;
@@ -43,7 +43,7 @@ GroupExpression *Memo::InsertExpression(std::shared_ptr<GroupExpression> gexpr,
4343
auto it = group_expressions_.find(gexpr.get());
4444

4545
if (it != group_expressions_.end()) {
46-
assert(target_group == UNDEFINED_GROUP ||
46+
PL_ASSERT(target_group == UNDEFINED_GROUP ||
4747
target_group == (*it)->GetGroupID());
4848
gexpr->SetGroupID((*it)->GetGroupID());
4949
return *it;

src/optimizer/operators.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Operator PhysicalSeqScan::make(
426426
oid_t get_id, std::shared_ptr<catalog::TableCatalogObject> table,
427427
std::string alias, std::vector<AnnotatedExpression> predicates,
428428
bool update) {
429-
assert(table != nullptr);
429+
PL_ASSERT(table != nullptr);
430430
PhysicalSeqScan *scan = new PhysicalSeqScan;
431431
scan->table_ = table;
432432
scan->table_alias = alias;
@@ -465,7 +465,7 @@ Operator PhysicalIndexScan::make(
465465
oid_t index_id, std::vector<oid_t> key_column_id_list,
466466
std::vector<ExpressionType> expr_type_list,
467467
std::vector<type::Value> value_list) {
468-
assert(table != nullptr);
468+
PL_ASSERT(table != nullptr);
469469
PhysicalIndexScan *scan = new PhysicalIndexScan;
470470
scan->table_ = table;
471471
scan->is_for_update = update;

test/sql/optimizer_sql_test.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ TEST_F(OptimizerSQLTests, SelectConstantTest) {
494494
}
495495

496496
TEST_F(OptimizerSQLTests, JoinTest) {
497+
// The original table
497498
// TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test VALUES (1, 22, 333);");
498499
// TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test VALUES (2, 11, 000);");
499500
// TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test VALUES (3, 33, 444);");
@@ -519,6 +520,16 @@ TEST_F(OptimizerSQLTests, JoinTest) {
519520
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test2 VALUES (3, 22, 555);");
520521
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test2 VALUES (4, 00, 000);");
521522

523+
// Create the fourth table
524+
TestingSQLUtil::ExecuteSQLQuery(
525+
"CREATE TABLE test3(a INT PRIMARY KEY, b INT, c INT);");
526+
527+
// Insert tuples into table
528+
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test3 VALUES (1, 22, 000);");
529+
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test3 VALUES (2, 11, 333);");
530+
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test3 VALUES (3, 22, 555);");
531+
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test3 VALUES (4, 00, 000);");
532+
522533
/************************* Basic Queries (only joins)
523534
* *******************************/
524535
// Product
@@ -637,6 +648,14 @@ TEST_F(OptimizerSQLTests, JoinTest) {
637648
"GROUP BY test.a "
638649
"ORDER BY test.a",
639650
{"22", "1", "11", "2", "22", "3", "0", "4"}, true);
651+
652+
// Basic 4 table join
653+
TestUtil(
654+
"SELECT test.a, test1.a, test2.a, test3.c FROM test, test1, test2, test3 "
655+
"WHERE test.a = test2.a AND test2.a = test1.a and test.b = test3.b",
656+
{"1", "1", "1", "0", "1", "1", "1", "555", "2", "2", "2", "333", "4",
657+
"4", "4", "0"},
658+
false);
640659
}
641660

642661
TEST_F(OptimizerSQLTests, IndexTest) {

0 commit comments

Comments
 (0)