Skip to content

Commit

Permalink
fix(optimizer): ban scalar subquery for project set (#8519)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 authored Mar 14, 2023
1 parent 428354d commit c11fb64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/frontend/planner_test/tests/testdata/subquery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,6 @@
Not supported: streaming nested-loop join
HINT: The non-equal join in the query requires a nested-loop join executor, which could be very expensive to run. Consider rewriting the query to use dynamic filter as a substitute if possible.
See also: https://github.com/risingwavelabs/rfcs/blob/main/rfcs/0033-dynamic-filter.md
- sql: |
SELECT 1, (SELECT regexp_matches('barbeque barbeque', '(bar)(beque)', 'g'))
batch_error: 'internal error: Scalar subquery might produce more than one row.'
12 changes: 8 additions & 4 deletions src/frontend/src/optimizer/plan_visitor/max_one_row_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::collections::HashSet;

use crate::optimizer::plan_node::{
LogicalAgg, LogicalApply, LogicalExpand, LogicalFilter, LogicalHopWindow, LogicalLimit,
LogicalNow, LogicalProject, LogicalProjectSet, LogicalTopN, LogicalUnion, LogicalValues,
PlanTreeNodeBinary, PlanTreeNodeUnary,
LogicalNow, LogicalProject, LogicalProjectSet, LogicalScan, LogicalTopN, LogicalUnion,
LogicalValues, PlanTreeNodeBinary, PlanTreeNodeUnary,
};
use crate::optimizer::plan_visitor::PlanVisitor;
use crate::optimizer::PlanTreeNode;
Expand Down Expand Up @@ -77,8 +77,12 @@ impl PlanVisitor<bool> for MaxOneRowVisitor {
plan.column_subsets().len() == 1 && self.visit(plan.input())
}

fn visit_logical_project_set(&mut self, plan: &LogicalProjectSet) -> bool {
plan.select_list().len() == 1 && self.visit(plan.input())
fn visit_logical_project_set(&mut self, _plan: &LogicalProjectSet) -> bool {
false
}

fn visit_logical_scan(&mut self, _plan: &LogicalScan) -> bool {
false
}

fn visit_logical_hop_window(&mut self, _plan: &LogicalHopWindow) -> bool {
Expand Down

0 comments on commit c11fb64

Please sign in to comment.