Skip to content

Commit

Permalink
fix: confusion with left and right due to copy-paste
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueFranky committed Dec 26, 2024
1 parent 0cbe44d commit 35668a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/observer/sql/optimizer/logical_plan_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ RC LogicalPlanGenerator::create_plan(SubQueryFilterStmt *filter_stmt, std::uniqu
for(const auto &unit: filter_stmt->filter_units()) {
std::unique_ptr<SubQueryPredicateLogicalOperator> op = std::make_unique<SubQueryPredicateLogicalOperator>(unit->comp());
if(unit->left().is_expr == false && unit->right().is_expr == false) { // 暂不支持两边都是subquery
LOG_ERROR("both sides of query condition is sub query");
return RC::INVALID_ARGUMENT;
}

Expand Down
5 changes: 3 additions & 2 deletions src/observer/sql/stmt/filter_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ See the Mulan PSL v2 for more details. */
#include "common/rc.h"
#include "storage/db/db.h"
#include "storage/table/table.h"
#include "sql/parser/expression_binder.h"

RC get_table_and_field(Db *db, Table *default_table, std::unordered_map<std::string, Table *> *tables,
const RelAttrSqlNode &attr, Table *&table, const FieldMeta *&field)
Expand Down Expand Up @@ -141,15 +142,15 @@ RC SubQueryFilterStmt::create_filter_unit(Db *db, Table *default_table, std::uno

switch(condition.right_type) {
case ConditionSqlNode::SideType::Expr: {
filter_unit->set_left(SubQueryFilterObj(std::move(condition.right_expression)));
filter_unit->set_right(SubQueryFilterObj(std::move(condition.right_expression)));
} break;
case ConditionSqlNode::SideType::SubQuery: {
Stmt *sub_query;
rc = SelectStmt::create(db, *condition.right_sub_query, sub_query);
if(OB_FAIL(rc)) {
return rc;
}
filter_unit->set_left(SubQueryFilterObj(std::unique_ptr<Stmt>(sub_query)));
filter_unit->set_right(SubQueryFilterObj(std::unique_ptr<Stmt>(sub_query)));
} break;
default: {
return RC::INVALID_ARGUMENT;
Expand Down

0 comments on commit 35668a5

Please sign in to comment.