You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2020/04/13 04:41:35 UTC

[spark] branch branch-3.0 updated: [SPARK-31419][SQL][DOCS] Document Table-valued Function and Inline Table

This is an automated email from the ASF dual-hosted git repository.

srowen pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 7ddbc76  [SPARK-31419][SQL][DOCS] Document Table-valued Function and Inline Table
7ddbc76 is described below

commit 7ddbc76158c4fe1a48cb0c99e102b173355055c8
Author: Huaxin Gao <hu...@us.ibm.com>
AuthorDate: Sun Apr 12 23:39:27 2020 -0500

    [SPARK-31419][SQL][DOCS] Document Table-valued Function and Inline Table
    
    ### What changes were proposed in this pull request?
    Document Table-valued Function and Inline Table
    
    ### Why are the changes needed?
    To make SQL Reference complete
    
    ### Does this PR introduce any user-facing change?
    Yes
    
    <img width="1050" alt="Screen Shot 2020-04-11 at 5 34 25 PM" src="https://user-images.githubusercontent.com/13592258/79057852-cedff880-7c1a-11ea-9e1e-7882594ab573.png">
    
    <img width="1050" alt="Screen Shot 2020-04-11 at 5 34 46 PM" src="https://user-images.githubusercontent.com/13592258/79057854-d4d5d980-7c1a-11ea-94cc-92ef1121fa43.png">
    
    <img width="1050" alt="Screen Shot 2020-04-10 at 7 36 00 PM" src="https://user-images.githubusercontent.com/13592258/79033391-c2986480-7b62-11ea-9d0a-6c60de823256.png">
    
    <img width="1051" alt="Screen Shot 2020-04-10 at 7 36 21 PM" src="https://user-images.githubusercontent.com/13592258/79033392-c5935500-7b62-11ea-88d4-e7d7812a7add.png">
    
    <img width="1051" alt="Screen Shot 2020-04-11 at 5 09 48 PM" src="https://user-images.githubusercontent.com/13592258/79057555-6ba09700-7c17-11ea-9683-16bbde63a529.png">
    
    Also, linked the newly added pages to select statement
    
    <img width="1050" alt="Screen Shot 2020-04-10 at 3 27 59 PM" src="https://user-images.githubusercontent.com/13592258/79027245-5147ba00-7b40-11ea-9b10-527fd9639958.png">
    
    ### How was this patch tested?
    Manually build and check
    
    Closes #28185 from huaxingao/tvf.
    
    Authored-by: Huaxin Gao <hu...@us.ibm.com>
    Signed-off-by: Sean Owen <sr...@gmail.com>
    (cherry picked from commit 310bef1ac76f48bffcae8e46eb7766a84cb9ef6b)
    Signed-off-by: Sean Owen <sr...@gmail.com>
---
 docs/_data/menu-sql.yaml                       |   4 +
 docs/sql-ref-syntax-qry-select-inline-table.md |  84 ++++++++++++++++
 docs/sql-ref-syntax-qry-select-tvf.md          | 131 +++++++++++++++++++++++++
 docs/sql-ref-syntax-qry-select.md              |   6 +-
 4 files changed, 222 insertions(+), 3 deletions(-)

diff --git a/docs/_data/menu-sql.yaml b/docs/_data/menu-sql.yaml
index 75efb30..b8c6e50 100644
--- a/docs/_data/menu-sql.yaml
+++ b/docs/_data/menu-sql.yaml
@@ -162,6 +162,10 @@
                   url: sql-ref-syntax-qry-select-setops.html
                 - text: TABLESAMPLE
                   url: sql-ref-syntax-qry-sampling.html
+                - text: Table-valued Function
+                  url: sql-ref-syntax-qry-select-tvf.html
+                - text: Inline Table
+                  url: sql-ref-syntax-qry-select-inline-table.html
             - text: EXPLAIN
               url: sql-ref-syntax-qry-explain.html
         - text: Auxiliary Statements
diff --git a/docs/sql-ref-syntax-qry-select-inline-table.md b/docs/sql-ref-syntax-qry-select-inline-table.md
new file mode 100644
index 0000000..7a53285
--- /dev/null
+++ b/docs/sql-ref-syntax-qry-select-inline-table.md
@@ -0,0 +1,84 @@
+---
+layout: global
+title: Inline Table
+displayTitle: Inline Table
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+An inline table is a temporary table created using a VALUES clause.
+
+### Syntax
+
+{% highlight sql %}
+VALUES ( expression [ , ... ] ) [ table_alias ]
+{% endhighlight %}
+
+### Parameters
+
+<dl>
+  <dt><code><em>expression</em></code></dt>
+  <dd>
+    Specifies a combination of one or more values, operators and SQL functions that results in a value.
+  </dd>
+</dl>
+<dl>
+  <dt><code><em>table_alias</em></code></dt>
+  <dd>
+    Specifies a temporary name with an optional column name list. <br><br>
+    <b>Syntax:</b>
+      <code>
+        [ AS ] table_name [ ( column_name [ , ... ] ) ]
+      </code>
+  </dd>
+</dl>
+
+### Examples
+
+{% highlight sql %}
+-- single row, without a table alias
+SELECT * FROM VALUES ("one", 1);
+  +----+----+
+  |col1|col2|
+  +----+----+
+  | one|   1|
+  +----+----+
+
+-- three rows with a table alias
+SELECT * FROM VALUES ("one", 1), ("two", 2), ("three", null) AS data(a, b);
+  +-----+----+
+  |    a|   b|
+  +-----+----+
+  |  one|   1|
+  |  two|   2|
+  |three|null|
+  +-----+----+
+
+-- complex types with a table alias
+SELECT * FROM VALUES ("one", array(0, 1)), ("two", array(2, 3)) AS data(a, b);
+  +---+------+
+  |  a|     b|
+  +---+------+
+  |one|[0, 1]|
+  |two|[2, 3]|
+  +---+------+
+{% endhighlight %}
+
+### Related Statement
+
+ * [SELECT](sql-ref-syntax-qry-select.html)
diff --git a/docs/sql-ref-syntax-qry-select-tvf.md b/docs/sql-ref-syntax-qry-select-tvf.md
new file mode 100644
index 0000000..bbfd870
--- /dev/null
+++ b/docs/sql-ref-syntax-qry-select-tvf.md
@@ -0,0 +1,131 @@
+---
+layout: global
+title: Table-valued Functions (TVF)
+displayTitle: Table-valued Functions (TVF)
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+A table-valued function (TVF) is a function that returns a relation or a set of rows.
+
+### Syntax
+
+{% highlight sql %}
+function_name ( expression [ , ... ] ) [ table_alias ]
+{% endhighlight %}
+
+### Parameters
+
+<dl>
+  <dt><code><em>expression</em></code></dt>
+  <dd>
+    Specifies a combination of one or more values, operators and SQL functions that results in a value.
+  </dd>
+</dl>
+<dl>
+  <dt><code><em>table_alias</em></code></dt>
+  <dd>
+    Specifies a temporary name with an optional column name list. <br><br>
+    <b>Syntax:</b>
+      <code>
+        [ AS ] table_name [ ( column_name [ , ... ] ) ]
+      </code>
+  </dd>
+</dl>
+
+### Supported Table-valued Functions
+
+<table class="table">
+  <thead>
+    <tr><th style="width:25%">Function</th><th>Argument Type(s)</th><th>Description</th></tr>
+  </thead>
+    <tr>
+      <td><b> range </b>( <i>end</i> )</td>
+      <td> Long </td>
+      <td>Creates a table with a single <code>LongType</code> column named <code>id</code>, containing rows in a range from 0 to <code>end</code> (exclusive) with step value 1.</td>
+    </tr>
+    <tr>
+      <td><b> range </b>( <i> start, end</i> )</td>
+      <td> Long, Long </td>
+      <td width="60%">Creates a table with a single <code>LongType</code> column named <code>id</code>, containing rows in a range from <code>start</code> to <code>end</code> (exclusive) with step value 1.</td>
+    </tr>
+    <tr>
+      <td><b> range </b>( <i> start, end, step</i> )</td>
+      <td> Long, Long, Long </td>
+      <td width="60%">Creates a table with a single <code>LongType</code> column named <code>id</code>, containing rows in a range from <code>start</code> to <code>end</code> (exclusive) with <code>step</code> value.</td>
+     </tr>
+    <tr>
+      <td><b> range </b>( <i> start, end, step, numPartitions</i> )</td>
+      <td> Long, Long, Long, Int </td>
+      <td width="60%">Creates a table with a single <code>LongType</code> column named <code>id</code>, containing rows in a range from <code>start</code> to <code>end</code> (exclusive) with <code>step</code> value, with partition number <code>numPartitions</code> specified. </td>
+    </tr>
+</table>
+
+### Examples
+
+{% highlight sql %}
+-- range call with end
+SELECT * FROM range(6 + cos(3));
+  +---+
+  | id|
+  +---+
+  |  0|
+  |  1|
+  |  2|
+  |  3|
+  |  4|
+  +---+
+
+-- range call with start and end
+SELECT * FROM range(5, 10);
+  +---+
+  | id|
+  +---+
+  |  5|
+  |  6|
+  |  7|
+  |  8|
+  |  9|
+  +---+
+
+-- range call with numPartitions
+SELECT * FROM range(0, 10, 2, 200);
+  +---+
+  | id|
+  +---+
+  |  0|
+  |  2|
+  |  4|
+  |  6|
+  |  8|
+  +---+
+
+-- range call with a table alias
+SELECT * FROM range(5, 8) AS test;
+  +---+
+  | id|
+  +---+
+  |  5|
+  |  6|
+  |  7|
+  +---+
+{% endhighlight %}
+
+### Related Statement
+
+ * [SELECT](sql-ref-syntax-qry-select.html)
diff --git a/docs/sql-ref-syntax-qry-select.md b/docs/sql-ref-syntax-qry-select.md
index f1585df..8ecc2c6 100644
--- a/docs/sql-ref-syntax-qry-select.md
+++ b/docs/sql-ref-syntax-qry-select.md
@@ -78,9 +78,9 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { named_expression [ , ... ] }
     Specifies a source of input for the query. It can be one of the following:
     <ol>
       <li>Table relation</li>
-      <li>Join relation</li>
-      <li>Table valued function</li>
-      <li>Inlined table</li>
+      <li><a href="sql-ref-syntax-qry-select-join.html">Join relation</a></li>
+      <li><a href="sql-ref-syntax-qry-select-tvf.html">Table-value function</a></li>
+      <li><a href="sql-ref-syntax-qry-select-inline-table.html">Inline table</a></li>
       <li>Subquery</li>
     </ol>
   </dd>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org