Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(planner): row handler not included when count(*) is used as subexpression #502

Merged
merged 2 commits into from
Feb 19, 2022
Merged

fix(planner): row handler not included when count(*) is used as subexpression #502

merged 2 commits into from
Feb 19, 2022

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Feb 19, 2022

fix #501

> explain select count(*) from t;
PhysicalProjection: exprs [InputRef #0]
  PhysicalSimpleAgg: 1 agg calls
    PhysicalTableScan: table #10, columns [], with_row_handler: true, is_sorted: false, expr: None

> explain select 1 from t;
PhysicalProjection: exprs [Int32(1) (const)]
  PhysicalTableScan: table #10, columns [], with_row_handler: false, is_sorted: false, expr: None

> explain select count(*)+1 from t;
PhysicalProjection: exprs [Plus(InputRef #0, Int32(1) (const))]
  PhysicalSimpleAgg: 1 agg calls
    PhysicalTableScan: table #10, columns [], with_row_handler: true, is_sorted: false, expr: None

> explain select -count(*) from t;
PhysicalProjection: exprs [BoundUnaryOp { op: Minus, expr: InputRef #0, return_type: Some(Int(None)) }]
  PhysicalSimpleAgg: 1 agg calls
    PhysicalTableScan: table #10, columns [], with_row_handler: true, is_sorted: false, expr: None

…pression

Signed-off-by: xxchan <xxchan22f@gmail.com>
@xxchan xxchan requested review from skyzh and Fedomn February 19, 2022 10:02
@xxchan
Copy link
Member Author

xxchan commented Feb 19, 2022

> explain select count(*)+sum(v) from t
PhysicalProjection: exprs [Plus(InputRef #0, InputRef #1)]
  PhysicalSimpleAgg: 2 agg calls
    PhysicalTableScan: table #10, columns [0], with_row_handler: false, is_sorted: false, expr: None

Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Would you please add the cases in issue body to sqllogictests?

By the way, I'm thinking of moving row-handler related logics to the optimizer... For example, if column pruning found that there's no column to scan, we automatically attach a row handler to the table.

At the same time, if our queries become more and more complex, it won't be possible for us to enumerate all rules to add row_handler column, solely in the planner... I don't have a clear idea about that, but I think we will eventually (1) make row_handler a real logical column instead of a flag for table (2) use the optimizer rule to decide whether to scan the row handler column.

Signed-off-by: xxchan <xxchan22f@gmail.com>
@xxchan xxchan enabled auto-merge (squash) February 19, 2022 10:30
@xxchan xxchan merged commit e0fd2e0 into risinglightdb:main Feb 19, 2022
@xxchan xxchan deleted the row_handler_expr branch February 19, 2022 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

planner: row handler not included when count(*) is used as subexpression
2 participants