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

The CLI panics when passing an invalid explain query #4429

Merged
merged 3 commits into from
Dec 1, 2022

Conversation

comphead
Copy link
Contributor

Which issue does this PR close?

Closes #4378 .

Rationale for this change

What changes are included in this PR?

Replace panics in favor if Error

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the logical-expr Logical plan and expressions label Nov 29, 2022
@comphead
Copy link
Contributor Author

Hi @HaoYang670 please check the PR
But tbh the optimizer doesn't respect errors now so the error message looks like

DataFusion CLI v14.0.0
❯ explain explain select 1;
Internal("Unsupported logical plan: Explain must be root of the plan")

jackwener
jackwener approved these changes Nov 30, 2022
@HaoYang670
Copy link
Contributor

Could we add a test for this?

@HaoYang670
Copy link
Contributor

HaoYang670 commented Nov 30, 2022

Hi @HaoYang670 please check the PR But tbh the optimizer doesn't respect errors now so the error message looks like

DataFusion CLI v14.0.0
❯ explain explain select 1;
Internal("Unsupported logical plan: Explain must be root of the plan")

Thank you for your contribution @comphead .
This is because the error is generated in the logical optimizer, but it is ignored as the configuration datafusion.optimizer.skip_failed_rules is set to `true by default:
https://github.com/apache/arrow-datafusion/blob/49166ea55f317722ab7a37fbfc253bcd497c1672/datafusion/optimizer/src/optimizer.rs#L248-L265

And the error message printed in CLI is created when generating physical plan:
https://github.com/apache/arrow-datafusion/blob/49166ea55f317722ab7a37fbfc253bcd497c1672/datafusion/core/src/physical_plan/planner.rs#L1093-L1095

Generally, we don't want to return an internal error to user, because it means that there are bugs in our project.
For the expain explain ... query, if it is invalid, we should return an error when parsing it, instead of when optimizing it.

cc @andygrove. Should this bug be fixed in sqlparser-rs or in datafusion?

@jackwener
Copy link
Member

jackwener commented Nov 30, 2022

Agree with @HaoYang670 , look like it should be fixed in sqlparser-rs.

It's error during parse.

@andygrove
Copy link
Member

I agree that the parser bug should be fixed in sqlparser-rs. It would also be nice to have a unit test for this change.

@github-actions github-actions bot added the core Core DataFusion crate label Nov 30, 2022
@comphead
Copy link
Contributor Author

Thanks @HaoYang670 @andygrove @jackwener added test

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @HaoYang670

@alamb alamb merged commit 0253459 into apache:master Dec 1, 2022
@ursabot
Copy link

ursabot commented Dec 1, 2022

Benchmark runs are scheduled for baseline = f8ec401 and contender = 0253459. 0253459 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The CLI panics when passing an invalid explain query
6 participants