-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 Expr::GetIndexedField
and GetFieldAccess
and always use function get_field
for indexing
#10374
Comments
One potential downside as @westonpace mentioned somewhere I can't find now, is that systems that want to look for field accesses for their own analysis (e.g. to find all nested field references) would find it harder to do so |
I think it would actually be easier. The easiest was the old way where we have only Today, I have to account for both paths. We use the SQL parser as our input. I don't know (off the top of my head) if it uses So having one path, even if it is a slightly less obvious path, is better than having two paths. |
@alamb Do you think we should also rewrite the array operator to function in parser step? It is currently in optimizer step. Have you thought about "user-defined" parser idea before, the way that user can define their own expression to get from the syntax? Is it useful in production? 🤔 |
I agree that changing the parser to insert a call to get field access directly is a good idea (and would be consistent and allow us to remove
One thing I have thought about is changing the hard coded lookup of function names from a pattern like this datafusion/datafusion/sql/src/expr/value.rs Lines 144 to 150 in fc34dac
To be something more structured pub trait PlannerFunctions {
/// return the UDF to use for creating arrays ("make_array") by default:
fn make_array(&self) -> Result<ScalarUDF>;
...
// similar functions for other built in functions
} And then instead of if let Some(udf) = self.context_provider.get_function_meta("make_array") {
Ok(Expr::ScalarFunction(ScalarFunction::new_udf(udf, values)))
} else {
not_impl_err!(
"array_expression featrue is disable, So should implement make_array UDF by yourself"
)
} The planner might look like let udf = self.planner_functions.make_array()?;
Ok(Expr::ScalarFunction(ScalarFunction::new_udf(udf, values))) But I haven't had a usecase to do that myself yet |
The array operator to function is syntax like |
Let's move the discussion to #10534 |
Is your feature request related to a problem or challenge?
Discussion starts from #10181 (comment)
Describe the solution you'd like
As title mentioned, use function instead of
Expr
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: