maropu commented on a change in pull request #28139: [SPARK-31362][SQL][DOCS] 
Document Set Operators in SQL Reference
URL: https://github.com/apache/spark/pull/28139#discussion_r404465589
 
 

 ##########
 File path: docs/sql-ref-syntax-qry-select-setops.md
 ##########
 @@ -19,4 +19,125 @@ license: |
   limitations under the License.
 ---
 
-**This page is under construction**
+Set operators are used to combine the results of two queries into a single 
result. Spark SQL supports three types of set operators:
+- `EXCEPT` and `EXCEPT ALL`
+- `INTERSECT` and `INTERSECT ALL`
+- `UNION` and `UNION ALL`
+
+Note that the queries' result sets must have the same number of columns and 
compatible data types for the respective columns.
+
+### EXCEPT and EXCEPT ALL
+`EXCEPT` and `EXCEPT ALL` return the rows that are found in one query but not 
the other query. `EXCEPT` takes only distinct rows while `EXCEPT ALL` does not 
remove duplicates.
+
+#### Syntax
+{% highlight sql %}
+[ ( ] query [ ) ] EXCEPT [ ALL ] [ ( ] query[ ) ]
+{% endhighlight %}
+
+### INTERSECT and INTERSECT ALL
+`INTERSECT` and `INTERSECT ALL` return the rows that are found in both 
queries. `INTERSECT` takes only distinct rows while `INTERSECT ALL` does not 
remove duplicates.
+
+#### Syntax
+{% highlight sql %}
+[ ( ] query [ ) ] INTERSECT [ ALL ] [ ( ] query [ ) ]
+{% endhighlight %}
+
+### UNION and UNION ALL
+`UNION` and `UNION ALL` return the rows that are found in either query. 
`UNION` takes only distinct rows while `UNION ALL` does not remove duplicates.
+
+#### Syntax
+{% highlight sql %}
+[ ( ] query [ ) ] UNION [ ALL ] [ ( ] query [ ) ]
+{% endhighlight %}
+
+### Examples
+{% highlight sql %}
+-- Use number1 and number2 tables to demonstrate set operators.
+SELECT * FROM number1;
++---+
+|  C|
 
 Review comment:
   super nit though... could the column name be lowercased for distinguishing 
it from the SQL keywords?

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to