maropu commented on a change in pull request #29355:
URL: https://github.com/apache/spark/pull/29355#discussion_r466771927



##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -21,35 +21,35 @@ 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;

Review comment:
       How about simply saying `1. A function that can be ...`

##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -98,8 +98,69 @@ 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|
++----+----+
+
+SELECT json_tuple('{"a":1, "b":2}', 'a', 'b');
++---+---+
+| c0| c1|
++---+---+
+|  1|  2|
++---+---+
+
+SELECT parse_url('http://spark.apache.org/path?query=1', 'HOST');
++-----------------------------------------------------+
+|parse_url(http://spark.apache.org/path?query=1, HOST)|
++-----------------------------------------------------+
+|                                     spark.apache.org|
++-----------------------------------------------------+
+
+-- Use explode in a LATERAL VIEW clause
+CREATE TABLE test (c1 INT);
+INSERT INTO test VALUES (1);
+INSERT INTO test VALUES (2);
+SELECT * FROM test LATERAL VIEW explode (ARRAY(3,4)) AS c2;
++--+--+
+|c1|c2|
++--+--+
+| 1| 3|
+| 1| 4|
+| 2| 3|
+| 2| 4|
++--+--+
 ```
 
 ### Related Statements
 
 * [SELECT](sql-ref-syntax-qry-select.html)
+* [LATERAL VIEW Clause](sql-ref-syntax-qry-select-lateral-view.html)

Review comment:
       Could you add a link in the LATERAL VIEW side to this page?
   
https://github.com/apache/spark/blame/master/docs/sql-ref-syntax-qry-select-lateral-view.md#L114

##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -21,35 +21,35 @@ 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 SELECT/LATERAL VIEW clauses, e.g. explode.
 
 ### Supported Table-valued Functions
 
+#### TVFs that can be specified in a FROM clause:
+
 |Function|Argument Type(s)|Description|
 |--------|----------------|-----------|
 |**range** ( *end* )|Long|Creates a table with a single *LongType* column 
named *id*, <br/> containing rows in a range from 0 to *end* (exclusive) with 
step value 1.|
 |**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.|
 
+#### TVFs that can be specified in SELECT/LATERAL VIEW clauses:
+
+|Function|Argument Type(s)|Description|
+|--------|----------------|-----------|
+|**explode** ( *expr* )|Array/Map|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.|
+|**explode_outer** <br> ( *expr* )|Array/Map|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.|
+|**inline** ( *expr* )|Expression|Explodes an array of structs into a table. 
Uses column names col1, col2, etc. by default unless specified otherwise.|

Review comment:
       I think `Expression` is not a type, so we should put a suitable type 
name here, struct? 
https://github.com/apache/spark/blame/master/docs/sql-ref-datatypes.md#L59

##########
File path: docs/sql-ref-syntax-qry-select-tvf.md
##########
@@ -21,35 +21,35 @@ 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 SELECT/LATERAL VIEW clauses, e.g. explode.
 
 ### Supported Table-valued Functions
 
+#### TVFs that can be specified in a FROM clause:
+
 |Function|Argument Type(s)|Description|
 |--------|----------------|-----------|
 |**range** ( *end* )|Long|Creates a table with a single *LongType* column 
named *id*, <br/> containing rows in a range from 0 to *end* (exclusive) with 
step value 1.|
 |**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.|
 
+#### TVFs that can be specified in SELECT/LATERAL VIEW clauses:

Review comment:
       Could you add a link to this section in 
https://github.com/apache/spark/blame/master/docs/sql-ref-syntax-qry-select-lateral-view.md#L40
 ?




----------------------------------------------------------------
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]

Reply via email to