You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "niebayes (via GitHub)" <gi...@apache.org> on 2025/01/09 15:44:19 UTC
[PR] fix get_valid_types with TypeSignature::Numeric [datafusion]
niebayes opened a new pull request, #14060:
URL: https://github.com/apache/datafusion/pull/14060
## Which issue does this PR close?
Closes #14059.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
Make `get_valid_types` handle TypeSignature::Numeric(n) correctly, for various n.
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
Yes, added a unit test.
## Are there any user-facing changes?
No.
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: make get_valid_types handle TypeSignature::Numeric correctly [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 merged PR #14060:
URL: https://github.com/apache/datafusion/pull/14060
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: make get_valid_types handle TypeSignature::Numeric correctly [datafusion]
Posted by "niebayes (via GitHub)" <gi...@apache.org>.
niebayes commented on code in PR #14060:
URL: https://github.com/apache/datafusion/pull/14060#discussion_r1909055517
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -551,6 +551,10 @@ fn get_valid_types(
// and their default type is double precision
if logical_data_type == NativeType::Null {
valid_type = DataType::Float64;
+ } else if !logical_data_type.is_numeric() {
+ return plan_err!(
+ "The signature expected NativeType::Numeric but received {logical_data_type}"
+ );
Review Comment:
I'm not entirely clear on the rationale for falling back to Float64 when the argument is of type Null.
However, I choose to keep this logic and make it a short-circuit before the numeric check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: make get_valid_types handle TypeSignature::Numeric correctly [datafusion]
Posted by "niebayes (via GitHub)" <gi...@apache.org>.
niebayes commented on PR #14060:
URL: https://github.com/apache/datafusion/pull/14060#issuecomment-2581654390
I need to bump Rust to 1.84 to pass CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: make get_valid_types handle TypeSignature::Numeric correctly [datafusion]
Posted by "niebayes (via GitHub)" <gi...@apache.org>.
niebayes commented on code in PR #14060:
URL: https://github.com/apache/datafusion/pull/14060#discussion_r1909076566
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -159,9 +159,7 @@ pub trait DynEq {
impl<T: Eq + Any> DynEq for T {
fn dyn_eq(&self, other: &dyn Any) -> bool {
- other
- .downcast_ref::<Self>()
- .map_or(false, |other| other == self)
+ other.downcast_ref::<Self>() == Some(self)
Review Comment:
fix clippy
##########
datafusion/physical-expr-common/src/sort_expr.rs:
##########
@@ -291,9 +291,9 @@ impl PhysicalSortRequirement {
/// Returns whether this requirement is equal or more specific than `other`.
pub fn compatible(&self, other: &PhysicalSortRequirement) -> bool {
self.expr.eq(&other.expr)
- && other.options.map_or(true, |other_opts| {
- self.options.map_or(false, |opts| opts == other_opts)
- })
+ && other
+ .options
+ .map_or(true, |other_opts| self.options == Some(other_opts))
Review Comment:
fix clippy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: make get_valid_types handle TypeSignature::Numeric correctly [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #14060:
URL: https://github.com/apache/datafusion/pull/14060#issuecomment-2584988703
Thanks @niebayes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: make get_valid_types handle TypeSignature::Numeric correctly [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #14060:
URL: https://github.com/apache/datafusion/pull/14060#discussion_r1909635152
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -551,6 +551,10 @@ fn get_valid_types(
// and their default type is double precision
if logical_data_type == NativeType::Null {
valid_type = DataType::Float64;
+ } else if !logical_data_type.is_numeric() {
+ return plan_err!(
+ "The signature expected NativeType::Numeric but received {logical_data_type}"
+ );
Review Comment:
f64 is chosen since it is the most compatible type of numeric
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org