somu-imply commented on code in PR #13736:
URL: https://github.com/apache/druid/pull/13736#discussion_r1096228358
##########
docs/querying/sql.md:
##########
@@ -82,6 +83,27 @@ FROM clause, metadata tables are not considered datasources.
They exist only in
For more information about table, lookup, query, and join datasources, refer
to the [Datasources](datasource.md)
documentation.
+## UNNEST
+
+The UNNEST clause unnests values stored in arrays within a column. It's the
SQL equivalent to the [unnest datasource](./datasource.md#unnest).
+
+The following is the general syntax for UNNEST, specifically a query that
returns the column that gets unnested:
+
+```sql
+SELECT target_column FROM datasource, UNNEST(source) as UNNESTED(target_column)
Review Comment:
The same query can be invoked as
```
SELECT foo.target_column FROM datasource, UNNEST(source) as
foo(target_column)
```
The unnested is not a mandatory keyword and user can use any name they want
as a table alias for the unnest. Think of this as unnest is a cross join
between two data sources and each can be aliased as a table name.
##########
docs/querying/sql.md:
##########
@@ -55,6 +55,7 @@ Druid SQL supports SELECT queries with the following
structure:
[ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
SELECT [ ALL | DISTINCT ] { * | exprs }
FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[, UNNEST(<input>) as unnested(<output>) ]
Review Comment:
UNNEST(<input>) as <table_alias>(<output>)
##########
docs/querying/sql-functions.md:
##########
@@ -1357,6 +1357,13 @@ Truncates a numerical expression to a specific number of
decimal digits.
Parses `expr` into a `COMPLEX<json>` object. This operator deserializes JSON
values when processing them, translating stringified JSON into a nested
structure. If the input is not a `VARCHAR` or it is invalid JSON, this function
will result in a `NULL` value.
+## UNNEST
+
+`UNNEST(source)) as UNNESTED (target)`
Review Comment:
This actually should be `UNNEST(source)) as table_alias_name
(column_alias_name)`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]