vtlim commented on code in PR #13736: URL: https://github.com/apache/druid/pull/13736#discussion_r1103376140
########## docs/tutorials/tutorial-unnest-arrays.md: ########## @@ -140,9 +142,93 @@ Now that the data is loaded, run the following query: SELECT * FROM nested_data ``` -In the results, notice that the column named `dim3` has nested values like `["a","b"]`. The example queries that follow unnest `dim3` and run queries, such as Scan. +In the results, notice that the column named `dim3` has nested values like `["a","b"]`. The example queries that follow unnest `dim3` and run queries against the unnested records. Depending on the type of queries you write, see either [Unnest using SQL queries](#unnest-using-sql-queries) or [Unnest using native queries](#unnest-using-native-queries). + +## Unnest using SQL queries + +The following is the general syntax for UNNEST: + +```sql +SELECT column_alias_name FROM datasource, UNNEST(source_expression) AS table_alias_name(column_alias_name) +``` + +For more information about the syntax, see [UNNEST](../querying/sql.md#unnest). + +### Unnest inline array + +The following query returns a column that unnests the array `[1,2,3]` that is provided inline: + +```sql +SELECT * FROM UNNEST(ARRAY[1,2,3]) +``` + +If you unnest that same inline array while using a table as the datasource, Druid treats this as a JOIN between a left datasource and a constant datasource. For example: + +```sql +SELECT longs FROM nested_data, UNNEST(ARRAY[1,2,3]) AS example_table (longs) Review Comment: Keep consistent on whether or not there's a space between the table alias and column alias? The general syntax in sql.md lists no space: ``` SELECT column_alias_name FROM datasource, UNNEST(source_expression) 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]
