This is an automated email from the ASF dual-hosted git repository. jakevin pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push: new 2d69ddb67a Docs: Improve documentation for `struct` function` (#6754) 2d69ddb67a is described below commit 2d69ddb67a10357216e76d6156678e1480c3c1ef Author: Andrew Lamb <and...@nerdnetworks.org> AuthorDate: Sat Jun 24 22:57:10 2023 -0400 Docs: Improve documentation for `struct` function` (#6754) --- docs/source/user-guide/sql/scalar_functions.md | 58 ++++++++++++++++++-------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md index fdd8aa70e4..c24b6dc91a 100644 --- a/docs/source/user-guide/sql/scalar_functions.md +++ b/docs/source/user-guide/sql/scalar_functions.md @@ -1606,6 +1606,47 @@ trim_array(array, n) Can be a constant, column, or function, and any combination of array operators. - **n**: Element to trim the array. +## Struct Functions + +- [struct](#struct) + +### `struct` + +Returns an Arrow struct using the specified input expressions. +Fields in the returned struct use the `cN` naming convention. +For example: `c0`, `c1`, `c2`, etc. + +``` +struct(expression1[, ..., expression_n]) +``` + +For example, this query converts two columns `a` and `b` to a single column with +a struct type of fields `c0` and `c1`: + +```sql +❯ select * from t; ++---+---+ +| a | b | ++---+---+ +| 1 | 2 | +| 3 | 4 | ++---+---+ + +❯ select struct(a, b) from t; ++-----------------+ +| struct(t.a,t.b) | ++-----------------+ +| {c0: 1, c1: 2} | +| {c0: 3, c1: 4} | ++-----------------+ +``` + +#### Arguments + +- **expression_n**: Expression to include in the output struct. + Can be a constant, column, or function, and any combination of arithmetic or + string operators. + ## Hashing Functions - [digest](#digest) @@ -1708,7 +1749,6 @@ sha512(expression) - [arrow_cast](#arrow_cast) - [arrow_typeof](#arrow_typeof) -- [struct](#struct) ### `arrow_cast` @@ -1739,19 +1779,3 @@ arrow_typeof(expression) - **expression**: Expression to evaluate. Can be a constant, column, or function, and any combination of arithmetic or string operators. - -### `struct` - -Returns an Arrow struct using the specified input expressions. -Fields in the returned struct use the `cN` naming convention. -For example: `c0`, `c1`, `c2`, etc. - -``` -struct(expression1[, ..., expression_n]) -``` - -#### Arguments - -- **expression_n**: Expression to include in the output struct. - Can be a constant, column, or function, and any combination of arithmetic or - string operators.