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

feat(frontend): print partial explain traces if there's error #9513

Merged
merged 8 commits into from
Apr 28, 2023

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Apr 27, 2023

Signed-off-by: Bugen Zhao [email protected]I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

This PR makes it possible to peek at the partial outputs of EXPLAIN if there's an error during plan generation and optimization. This may be helpful for us to develop a new feature or optimizer rule.

dev=> create table t (v int);
CREATE_TABLE
dev=> explain(trace) select (select v from t), 1 from t;
                                    QUERY PLAN                                     
-----------------------------------------------------------------------------------
 Begin:
 
 LogicalProject { exprs: [t.v, 1:Int32] }
 └─LogicalApply { type: LeftOuter, on: true, correlated_id: 1, max_one_row: true }
   ├─LogicalScan { table: t, columns: [v, _row_id] }
   └─LogicalProject { exprs: [t.v] }
     └─LogicalScan { table: t, columns: [v, _row_id] }
 
 ERROR: internal error: Scalar subquery might produce more than one row.
(9 rows)

For example, if we're working on a logical plan node and are sure that its to_stream won't work for now, we can now use explain(logical) to get the logical plan. Previously, this can only be achieved with the planner test.

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

  • I have requested macro/micro-benchmarks as this PR can affect performance substantially, and the results are shown.

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Comment on lines +45 to +46
// Workaround to avoid `Rc` across `await` point.
let mut batch_plan_fragmenter = None;
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, most of the time I spent on this PR is struggling with Rc and Send. 🥵 I guess either we need a refactor to split blocking steps off the planning, or we may migrate to thread-safe structures to make developing easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ❤️ 🥵 #9515

@BugenZhao BugenZhao requested a review from st1page April 27, 2023 10:03
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #9513 (f7bdaf9) into main (73f000e) will increase coverage by 0.00%.
The diff coverage is 71.31%.

@@           Coverage Diff           @@
##             main    #9513   +/-   ##
=======================================
  Coverage   70.78%   70.78%           
=======================================
  Files        1231     1231           
  Lines      206195   206218   +23     
=======================================
+ Hits       145945   145966   +21     
- Misses      60250    60252    +2     
Flag Coverage Δ
rust 70.78% <71.31%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/frontend/src/handler/explain.rs 72.15% <70.40%> (-2.49%) ⬇️
src/frontend/src/optimizer/optimizer_context.rs 88.09% <100.00%> (+0.29%) ⬆️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

script = "RUST_BACKTRACE=full target/${BUILD_MODE_DIR}/risedev-dev ${@}"
script = "RUST_BACKTRACE=1 target/${BUILD_MODE_DIR}/risedev-dev ${@}"
Copy link
Contributor

Choose a reason for hiding this comment

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

👀 LGTM

Comment on lines +45 to +46
// Workaround to avoid `Rc` across `await` point.
let mut batch_plan_fragmenter = None;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ❤️ 🥵 #9515

@BugenZhao BugenZhao added this pull request to the merge queue Apr 28, 2023
Merged via the queue into main with commit 9de56c8 Apr 28, 2023
@BugenZhao BugenZhao deleted the bz/better-explain branch April 28, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants