Skip to content

Commit

Permalink
Implement array_slice and array_element, remove array_trim (#6936)
Browse files Browse the repository at this point in the history
* feat: reading array elements

* feat: array_element, array_slice, struct_extract

* feat: support for positive and zero numbers for array_element and array_slice

* feat: support negative numbers for array_element and array_slice

* feat: add more sql logic tests for array_element and array_slice

* feat: unit tests for get indexed fields

* feat: sqllogictests for index

* docs: array_element and array_slice

* feat: some TODOS

* feat: proto

* feat: proto

* fix: tests

* fix: query_nested_get_indexed_field_on_struct

* fix: some bugs

* fix: typo

* test: remove test_udaf_returning_struct_subquery

* feat: column support for list with single index

* fix: list index does not support with columns

* fix: proto

* fix: proto test

* fix: clippy

* fix: test_udaf_returning_struct_subquery
  • Loading branch information
izveigor authored Aug 4, 2023
1 parent 02da044 commit 2354758
Show file tree
Hide file tree
Showing 29 changed files with 1,979 additions and 597 deletions.
23 changes: 21 additions & 2 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,28 @@ fn create_physical_name(e: &Expr, is_first_expr: bool) -> Result<String> {
let expr = create_physical_name(expr, false)?;
Ok(format!("{expr} IS NOT UNKNOWN"))
}
Expr::GetIndexedField(GetIndexedField { key, expr }) => {
Expr::GetIndexedField(GetIndexedField {
key,
extra_key,
expr,
}) => {
let expr = create_physical_name(expr, false)?;
Ok(format!("{expr}[{key}]"))

if let (Some(list_key), Some(extra_key)) = (&key.list_key, extra_key) {
let key = create_physical_name(list_key, false)?;
let extra_key = create_physical_name(extra_key, false)?;
Ok(format!("{expr}[{key}:{extra_key}]"))
} else {
let key = if let Some(list_key) = &key.list_key {
create_physical_name(list_key, false)?
} else if let Some(ScalarValue::Utf8(Some(struct_key))) = &key.struct_key
{
struct_key.to_string()
} else {
String::from("")
};
Ok(format!("{expr}[{key}]"))
}
}
Expr::ScalarFunction(func) => {
create_function_physical_name(&func.fun.to_string(), false, &func.args)
Expand Down
Loading

0 comments on commit 2354758

Please sign in to comment.