maropu commented on a change in pull request #29355:
URL: https://github.com/apache/spark/pull/29355#discussion_r466158424
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -21,25 +21,7 @@ license: |
### Description
-A table-valued function (TVF) is a function that returns a relation or a set
of rows.
-
-### Syntax
-
-```sql
-function_name ( expression [ , ... ] ) [ table_alias ]
-```
-
-### Parameters
-
-* **expression**
-
- Specifies a combination of one or more values, operators and SQL functions
that results in a value.
-
-* **table_alias**
-
- Specifies a temporary name with an optional column name list.
-
- **Syntax:** `[ AS ] table_name [ ( column_name [ , ... ] ) ]`
+A table-valued function (TVF) is a function that returns a relation or a set
of rows. There are two types of TVFs in Spark SQL: 1) A TVF that can be
specified in a FROM clause, e.g. range; 2) A TVF that can be specified in a
SELECT clause, e.g. explode.
Review comment:
nit: `a SELECT clause` -> `SELECT/LATERAL VIEW clauses`?
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -98,6 +87,39 @@ SELECT * FROM range(5, 8) AS test;
| 6|
| 7|
+---+
+
+SELECT explode(array(10, 20));
++---+
+|col|
++---+
+| 10|
+| 20|
++---+
+
+SELECT inline(array(struct(1, 'a'), struct(2, 'b')));
++----+----+
+|col1|col2|
++----+----+
+| 1| a|
+| 2| b|
++----+----+
+
+SELECT posexplode(array(10,20));
++---+---+
+|pos|col|
++---+---+
+| 0| 10|
+| 1| 20|
++---+---+
+
+SELECT stack(2, 1, 2, 3);
++----+----+
+|col0|col1|
++----+----+
+| 1| 2|
+| 3|null|
++----+----+
+
Review comment:
nit: remove the blank.
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -21,25 +21,7 @@ license: |
### Description
-A table-valued function (TVF) is a function that returns a relation or a set
of rows.
-
-### Syntax
-
-```sql
-function_name ( expression [ , ... ] ) [ table_alias ]
-```
-
-### Parameters
-
-* **expression**
-
- Specifies a combination of one or more values, operators and SQL functions
that results in a value.
-
-* **table_alias**
-
- Specifies a temporary name with an optional column name list.
-
- **Syntax:** `[ AS ] table_name [ ( column_name [ , ... ] ) ]`
+A table-valued function (TVF) is a function that returns a relation or a set
of rows. There are two types of TVFs in Spark SQL: 1) A TVF that can be
specified in a FROM clause, e.g. range; 2) A TVF that can be specified in a
SELECT clause, e.g. explode.
Review comment:
nit: `A TVF` -> `a TVF`
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -49,6 +31,13 @@ function_name ( expression [ , ... ] ) [ table_alias ]
|**range** ( *start, end* )|Long, Long|Creates a table with a single
*LongType* column named *id*, <br/> containing rows in a range from *start* to
*end* (exclusive) with step value 1.|
|**range** ( *start, end, step* )|Long, Long, Long|Creates a table with a
single *LongType* column named *id*, <br/> containing rows in a range from
*start* to *end* (exclusive) with *step* value.|
|**range** ( *start, end, step, numPartitions* )|Long, Long, Long, Int|Creates
a table with a single *LongType* column named *id*, <br/> containing rows in a
range from *start* to *end* (exclusive) with *step* value, with partition
number *numPartitions* specified.|
+|**explode** ( *expr* )|Expression|Separates the elements of array *expr* into
multiple rows, or the elements of map *expr* into multiple rows and columns.
Unless specified otherwise, uses the default column name col for elements of
the array or key and value for the elements of the map.|
Review comment:
`Expression` -> `array or map`?
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -98,6 +87,39 @@ SELECT * FROM range(5, 8) AS test;
| 6|
| 7|
+---+
+
+SELECT explode(array(10, 20));
++---+
+|col|
++---+
+| 10|
+| 20|
++---+
+
+SELECT inline(array(struct(1, 'a'), struct(2, 'b')));
++----+----+
+|col1|col2|
++----+----+
+| 1| a|
+| 2| b|
++----+----+
+
+SELECT posexplode(array(10,20));
++---+---+
+|pos|col|
++---+---+
+| 0| 10|
+| 1| 20|
++---+---+
+
+SELECT stack(2, 1, 2, 3);
++----+----+
+|col0|col1|
++----+----+
+| 1| 2|
+| 3|null|
++----+----+
+
```
### Related Statements
Review comment:
How about adding a link to `sql-ref-syntax-qry-select-lateral-view.md`?
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -49,6 +31,13 @@ function_name ( expression [ , ... ] ) [ table_alias ]
|**range** ( *start, end* )|Long, Long|Creates a table with a single
*LongType* column named *id*, <br/> containing rows in a range from *start* to
*end* (exclusive) with step value 1.|
|**range** ( *start, end, step* )|Long, Long, Long|Creates a table with a
single *LongType* column named *id*, <br/> containing rows in a range from
*start* to *end* (exclusive) with *step* value.|
|**range** ( *start, end, step, numPartitions* )|Long, Long, Long, Int|Creates
a table with a single *LongType* column named *id*, <br/> containing rows in a
range from *start* to *end* (exclusive) with *step* value, with partition
number *numPartitions* specified.|
+|**explode** ( *expr* )|Expression|Separates the elements of array *expr* into
multiple rows, or the elements of map *expr* into multiple rows and columns.
Unless specified otherwise, uses the default column name col for elements of
the array or key and value for the elements of the map.|
Review comment:
How about making a new table for these new entries?
##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -98,6 +87,39 @@ SELECT * FROM range(5, 8) AS test;
| 6|
| 7|
+---+
+
+SELECT explode(array(10, 20));
Review comment:
How about adding examples with LATERAL VIEW?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]