Skip to content

Commit 1abe5b8

Browse files
committed
Fix
1 parent c7001b7 commit 1abe5b8

8 files changed

Lines changed: 155 additions & 117 deletions

docs/sql-ref-syntax-qry-select-distribute-by.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>DISTRIBUTE BY</code> clause is used to repartition the data based
2225
on the input expressions. Unlike the [CLUSTER BY](sql-ref-syntax-qry-select-clusterby.html)
2326
clause, this does not sort the data within each partition.

docs/sql-ref-syntax-qry-select-groupby.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>GROUP BY</code> clause is used to group the rows based on a set of specified grouping expressions and compute aggregations on
2225
the group of rows based on one or more specified aggregate functions. Spark also supports advanced aggregations to do multiple
2326
aggregations for the same input record set via `GROUPING SETS`, `CUBE`, `ROLLUP` clauses.

docs/sql-ref-syntax-qry-select-having.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>HAVING</code> clause is used to filter the results produced by
2225
<code>GROUP BY</code> based on the specified condition. It is often used
2326
in conjunction with a [GROUP BY](sql-ref-syntax-qry-select-groupby.html)

docs/sql-ref-syntax-qry-select-limit.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>LIMIT</code> clause is used to constrain the number of rows returned by
2225
the [SELECT](sql-ref-syntax-qry-select.html) statement. In general, this clause
2326
is used in conjunction with [ORDER BY](sql-ref-syntax-qry-select-orderby.html) to

docs/sql-ref-syntax-qry-select-orderby.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>ORDER BY</code> clause is used to return the result rows in a sorted manner
2225
in the user specified order. Unlike the [SORT BY](sql-ref-syntax-qry-select-sortby.html)
2326
clause, this clause guarantees a total order in the output.

docs/sql-ref-syntax-qry-select-setops.md

Lines changed: 134 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -19,159 +19,176 @@ license: |
1919
limitations under the License.
2020
---
2121

22+
### Description
23+
2224
Set operators are used to combine two input relations into a single one. Spark SQL supports three types of set operators:
23-
- `EXCEPT` or `MINUS`
24-
- `INTERSECT`
25-
- `UNION`
25+
26+
- `EXCEPT` or `MINUS`
27+
- `INTERSECT`
28+
- `UNION`
2629

2730
Note that input relations must have the same number of columns and compatible data types for the respective columns.
2831

2932
### EXCEPT
33+
3034
`EXCEPT` and `EXCEPT ALL` return the rows that are found in one relation but not the other. `EXCEPT` (alternatively, `EXCEPT DISTINCT`) takes only distinct rows while `EXCEPT ALL` does not remove duplicates from the result rows. Note that `MINUS` is an alias for `EXCEPT`.
3135

3236
#### Syntax
37+
3338
{% highlight sql %}
3439
[ ( ] relation [ ) ] EXCEPT | MINUS [ ALL | DISTINCT ] [ ( ] relation [ ) ]
3540
{% endhighlight %}
3641

37-
### INTERSECT
38-
`INTERSECT` and `INTERSECT ALL` return the rows that are found in both relations. `INTERSECT` (alternatively, `INTERSECT DISTINCT`) takes only distinct rows while `INTERSECT ALL` does not remove duplicates from the result rows.
42+
#### Examples
3943

40-
#### Syntax
4144
{% highlight sql %}
42-
[ ( ] relation [ ) ] INTERSECT [ ALL | DISTINCT ] [ ( ] relation [ ) ]
43-
{% endhighlight %}
44-
45-
### UNION
46-
`UNION` and `UNION ALL` return the rows that are found in either relation. `UNION` (alternatively, `UNION DISTINCT`) takes only distinct rows while `UNION ALL` does not remove duplicates from the result rows.
47-
48-
#### Syntax
49-
{% highlight sql %}
50-
[ ( ] relation [ ) ] UNION [ ALL | DISTINCT ] [ ( ] relation [ ) ]
51-
{% endhighlight %}
52-
53-
### Examples
54-
{% highlight sql %}
55-
-- Use number1 and number2 tables to demonstrate set operators.
45+
-- Use number1 and number2 tables to demonstrate set operators in this page.
5646
SELECT * FROM number1;
57-
+---+
58-
| c|
59-
+---+
60-
| 3|
61-
| 1|
62-
| 2|
63-
| 2|
64-
| 3|
65-
| 4|
66-
+---+
67-
47+
+---+
48+
| c|
49+
+---+
50+
| 3|
51+
| 1|
52+
| 2|
53+
| 2|
54+
| 3|
55+
| 4|
56+
+---+
57+
6858
SELECT * FROM number2;
69-
+---+
70-
| c|
71-
+---+
72-
| 5|
73-
| 1|
74-
| 2|
75-
| 2|
76-
+---+
59+
+---+
60+
| c|
61+
+---+
62+
| 5|
63+
| 1|
64+
| 2|
65+
| 2|
66+
+---+
7767

7868
SELECT c FROM number1 EXCEPT SELECT c FROM number2;
79-
+---+
80-
| c|
81-
+---+
82-
| 3|
83-
| 4|
84-
+---+
69+
+---+
70+
| c|
71+
+---+
72+
| 3|
73+
| 4|
74+
+---+
8575

8676
SELECT c FROM number1 MINUS SELECT c FROM number2;
87-
+---+
88-
| c|
89-
+---+
90-
| 3|
91-
| 4|
92-
+---+
77+
+---+
78+
| c|
79+
+---+
80+
| 3|
81+
| 4|
82+
+---+
9383

9484
SELECT c FROM number1 EXCEPT ALL (SELECT c FROM number2);
95-
+---+
96-
| c|
97-
+---+
98-
| 3|
99-
| 3|
100-
| 4|
101-
+---+
85+
+---+
86+
| c|
87+
+---+
88+
| 3|
89+
| 3|
90+
| 4|
91+
+---+
10292

10393
SELECT c FROM number1 MINUS ALL (SELECT c FROM number2);
104-
+---+
105-
| c|
106-
+---+
107-
| 3|
108-
| 3|
109-
| 4|
110-
+---+
94+
+---+
95+
| c|
96+
+---+
97+
| 3|
98+
| 3|
99+
| 4|
100+
+---+
101+
{% endhighlight %}
111102

103+
### INTERSECT
104+
105+
`INTERSECT` and `INTERSECT ALL` return the rows that are found in both relations. `INTERSECT` (alternatively, `INTERSECT DISTINCT`) takes only distinct rows while `INTERSECT ALL` does not remove duplicates from the result rows.
106+
107+
#### Syntax
108+
109+
{% highlight sql %}
110+
[ ( ] relation [ ) ] INTERSECT [ ALL | DISTINCT ] [ ( ] relation [ ) ]
111+
{% endhighlight %}
112+
113+
#### Examples
114+
115+
{% highlight sql %}
112116
(SELECT c FROM number1) INTERSECT (SELECT c FROM number2);
113-
+---+
114-
| c|
115-
+---+
116-
| 1|
117-
| 2|
118-
+---+
117+
+---+
118+
| c|
119+
+---+
120+
| 1|
121+
| 2|
122+
+---+
119123

120124
(SELECT c FROM number1) INTERSECT DISTINCT (SELECT c FROM number2);
121-
+---+
122-
| c|
123-
+---+
124-
| 1|
125-
| 2|
126-
+---+
125+
+---+
126+
| c|
127+
+---+
128+
| 1|
129+
| 2|
130+
+---+
127131

128132
(SELECT c FROM number1) INTERSECT ALL (SELECT c FROM number2);
129-
+---+
130-
| c|
131-
+---+
132-
| 1|
133-
| 2|
134-
| 2|
135-
+---+
133+
+---+
134+
| c|
135+
+---+
136+
| 1|
137+
| 2|
138+
| 2|
139+
+---+
140+
{% endhighlight %}
141+
142+
### UNION
136143

144+
`UNION` and `UNION ALL` return the rows that are found in either relation. `UNION` (alternatively, `UNION DISTINCT`) takes only distinct rows while `UNION ALL` does not remove duplicates from the result rows.
145+
146+
#### Syntax
147+
148+
{% highlight sql %}
149+
[ ( ] relation [ ) ] UNION [ ALL | DISTINCT ] [ ( ] relation [ ) ]
150+
{% endhighlight %}
151+
152+
### Examples
153+
154+
{% highlight sql %}
137155
(SELECT c FROM number1) UNION (SELECT c FROM number2);
138-
+---+
139-
| c|
140-
+---+
141-
| 1|
142-
| 3|
143-
| 5|
144-
| 4|
145-
| 2|
146-
+---+
156+
+---+
157+
| c|
158+
+---+
159+
| 1|
160+
| 3|
161+
| 5|
162+
| 4|
163+
| 2|
164+
+---+
147165

148166
(SELECT c FROM number1) UNION DISTINCT (SELECT c FROM number2);
149-
+---+
150-
| c|
151-
+---+
152-
| 1|
153-
| 3|
154-
| 5|
155-
| 4|
156-
| 2|
157-
+---+
167+
+---+
168+
| c|
169+
+---+
170+
| 1|
171+
| 3|
172+
| 5|
173+
| 4|
174+
| 2|
175+
+---+
158176

159177
SELECT c FROM number1 UNION ALL (SELECT c FROM number2);
160-
+---+
161-
| c|
162-
+---+
163-
| 3|
164-
| 1|
165-
| 2|
166-
| 2|
167-
| 3|
168-
| 4|
169-
| 5|
170-
| 1|
171-
| 2|
172-
| 2|
173-
+---+
174-
178+
+---+
179+
| c|
180+
+---+
181+
| 3|
182+
| 1|
183+
| 2|
184+
| 2|
185+
| 3|
186+
| 4|
187+
| 5|
188+
| 1|
189+
| 2|
190+
| 2|
191+
+---+
175192
{% endhighlight %}
176193

177194
### Related Statements

docs/sql-ref-syntax-qry-select-sortby.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>SORT BY</code> clause is used to return the result rows sorted
2225
within each partition in the user specified order. When there is more than one partition
2326
<code>SORT BY</code> may return result that is partially ordered. This is different

docs/sql-ref-syntax-qry-select-where.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
22+
### Description
23+
2124
The <code>WHERE</code> clause is used to limit the results of the <code>FROM</code>
2225
clause of a query or a subquery based on the specified condition.
2326

0 commit comments

Comments
 (0)