-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove physical expr of NamedStructField, convert to get_field
function call
#9563
Conversation
Self::new() | ||
} | ||
} | ||
|
||
impl ScalarUDFImpl for StructFunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last PR I make StructFunc pub so I add the Default trait, but since #9546 (comment) it will not be needed.
args, | ||
), | ||
))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the method from #9546 (comment), but it seems that here it can't get the context_provider
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only sql crate can get it directly, or any other crate that has context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could implement this rewrite more easily using the API proposed in #9583 (so you could use datafusion_functions directly)
} | ||
|
||
let arr; | ||
let array = match &args[0] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe try values_to_arrays
?
impl GetFieldFunc { | ||
pub fn new() -> Self { | ||
Self { | ||
signature: Signature::any(2, Volatility::Immutable), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems the signature should be struct
and utf8
. But, we can set it to Any
and utf8
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can also be Map
and utf8
.
A question for me is how to specify the Any as the param in Signature?
I tried Signature::exact(vec![Any, DataType::Utf8], Volatility::Immutable)
but it said
expected value, found trait
Any
not a value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep it as any(2) for now. I forgot that it is better to introduce signature only if we need type coercion.
datafusion/optimizer/Cargo.toml
Outdated
@@ -45,6 +45,7 @@ async-trait = { workspace = true } | |||
chrono = { workspace = true } | |||
datafusion-common = { workspace = true, default-features = true } | |||
datafusion-expr = { workspace = true } | |||
datafusion-functions = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is very important to not add this dependency -- we are triyng to make the core not know about the functions
I think #9583 will let us avoid it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I can wait on it and use that function.
Hi @alamb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @yyy1000 for this contribution as well as for making it so easy to review these PRs (with annotations explaining potentially non obvious changes)
This is a wonderful change / simplification
@@ -222,12 +225,10 @@ fn create_physical_name(e: &Expr, is_first_expr: bool) -> Result<String> { | |||
stride: _, | |||
} => { | |||
unreachable!( | |||
"ListIndex should have been rewritten in OperatorToFunction" | |||
"ListRange should have been rewritten in OperatorToFunction" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
get_field
function call
Thank you @alamb @jayzhan211 for your reviews and guidance! |
Which issue does this PR close?
Closes #9532 .
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?