Skip to content

Conversation

@liukun4515
Copy link
Contributor

Which issue does this PR close?

minor fix for negative operation in

  1. negative physical expr
  2. negative for scalar value

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@liukun4515 liukun4515 marked this pull request as ready for review September 6, 2022 08:24
@github-actions github-actions bot added the physical-expr Changes to the physical-expr crates label Sep 6, 2022
arg: Arc<dyn PhysicalExpr>,
input_schema: &Schema,
) -> Result<Arc<dyn PhysicalExpr>> {
// TODO: the data type checker should be done in the logical plan phase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If datafusion dose this in the preview stage or the logical plan generation stage, I think we don't need to check the child/input data type for the physical expr generation.

cc @alamb
Is there user case that user generate the physical plan or physical expr directly without the logical plan or logical stage?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if anyone creates physical Exprs directly without a logical_plan Expr.

However, I agree with this approach to throw an error if the physical types don't line up -- automatic coercion should be done at the logical level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if anyone creates physical Exprs directly without a logical_plan Expr.

However, I agree with this approach to throw an error if the physical types don't line up -- automatic coercion should be done at the logical level

Got it.
If the phy expr can be created directly without the type coercion or type checker in the logical phase, we need this checker in the creation of physical expr.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the phy expr can be created directly without the type coercion or type checker in the logical phase, we need this checker in the creation of physical expr.

That is a good point.

Maybe the larger question is if we are ok requiring that the logical optimizer passes are run on LogicalPlans and Expr to successfully create ExecutionPlans and PhysicalExprs,

Now that I type that it seems there is value in supporting creating Exprs and then PhysicalExprs directly (as part of implementing extensions, for example) 🤔 So maybe we should just ensure it is possible to call the coercion logic directly on a Expr

Ok(ScalarValue::Decimal128(Some(-v), *precision, *scale))
}
_ => panic!("Cannot run arithmetic negate on scalar value: {:?}", self),
value => Err(DataFusionError::Internal(format!(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace the panic with the error
cc @andygrove

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@liukun4515 liukun4515 requested a review from alamb September 6, 2022 11:18
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.

LGTM -- thanks @liukun4515

arg: Arc<dyn PhysicalExpr>,
input_schema: &Schema,
) -> Result<Arc<dyn PhysicalExpr>> {
// TODO: the data type checker should be done in the logical plan phase
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if anyone creates physical Exprs directly without a logical_plan Expr.

However, I agree with this approach to throw an error if the physical types don't line up -- automatic coercion should be done at the logical level

@andygrove andygrove merged commit 08a85db into apache:master Sep 6, 2022
@ursabot
Copy link

ursabot commented Sep 6, 2022

Benchmark runs are scheduled for baseline = 01d8730 and contender = 08a85db. 08a85db 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

physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants