Skip to content

Fix up some DataFusionError::Internal errors with correct type#6721

Merged
alamb merged 2 commits intoapache:mainfrom
alamb:alamb/audit_internal
Jun 21, 2023
Merged

Fix up some DataFusionError::Internal errors with correct type#6721
alamb merged 2 commits intoapache:mainfrom
alamb:alamb/audit_internal

Conversation

@alamb
Copy link
Copy Markdown
Contributor

@alamb alamb commented Jun 19, 2023

Which issue does this PR close?

Part of #6108

Rationale for this change

See rationale on #6108

What changes are included in this PR?

Change some errors that don't indicate a code bug in DataFusion to DataFusionError::Execution or DataFusionError::Plan

I can't think of any way to avoid allowing new Internal errors to be introduced, but if others have thoughts in that area I would appreciate them

Are these changes tested?

yes, existing tests

Are there any user-facing changes?

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates sql SQL Planner substrait Changes to the substrait crate labels Jun 19, 2023
@alamb alamb force-pushed the alamb/audit_internal branch from 7721b91 to 3f5baa7 Compare June 20, 2023 10:49
@github-actions github-actions Bot added the logical-expr Logical plan and expressions label Jun 20, 2023
@alamb alamb marked this pull request as ready for review June 20, 2023 13:27
@alamb
Copy link
Copy Markdown
Contributor Author

alamb commented Jun 20, 2023

cc @wolffcm I am making progress

))
}
}
other => Err(DataFusionError::Internal(format!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be here Execution as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this error is if calculate_result_decimal_for_avg gets called with a non DataType::Decimal argument, which I think the type dispatch is supposed to prevent.

Thus I think Internal is still the appropriate error in this area


result.cloned().ok_or_else(|| {
DataFusionError::Internal(format!(
DataFusionError::Plan(format!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

prob we could have short methods

plan_err(text)
execution_err(text)
...

to replace wordy

            DataFusionError::Plan(format!(
               text
            ))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is an excellent idea. I will try to do this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to implement this idea in #6740 but I found them harder / less easy to use

@alamb alamb merged commit 3908411 into apache:main Jun 21, 2023
@alamb alamb deleted the alamb/audit_internal branch June 21, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates sql SQL Planner substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants