[SPARK-31110][DOCS][SQL] refine sql doc for SELECT#27866
[SPARK-31110][DOCS][SQL] refine sql doc for SELECT#27866cloud-fan wants to merge 4 commits intoapache:masterfrom
Conversation
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
There was a problem hiding this comment.
My editor removes trailing spaces automatically
| {% highlight sql %} | ||
| GROUP BY [ GROUPING SETS grouping_sets ] group_expression [ , group_expression [ , ... ] ] | ||
| [ ( WITH ROLLUP | WITH CUBE | GROUPING SETS grouping_sets ) ) ] | ||
| [ ( WITH ROLLUP | WITH CUBE | GROUPING SETS grouping_sets ) ] |
There was a problem hiding this comment.
remove the extra )
| <code> ((warehouse, product), (warehouse), ())</code>. | ||
| Specifies multiple levels of aggregations in a single statement. This clause is used to compute aggregations | ||
| based on multiple grouping sets. <code>ROLLUP</code> is a shorthand for <code>GROUPING SETS</code>. For example, | ||
| <code>GROUP BY warehouse, product WITH ROLLUP</code> is equivalent to <code>GROUP BY GROUPING SETS |
There was a problem hiding this comment.
GROUP BY GROUPING SETS ... is the same as GROUP BY a, b GROUPING SETS but shorter.
| sort order is <code>DESC</code>.<br><br> | ||
| Optionally specifies whether NULL values are returned before/after non-NULL values. If | ||
| <code>null_sort_order</code> is not specified, then NULLs sort first if sort order is | ||
| <code>ASC</code> and NULLS sort last if sort order is <code>DESC</code>.<br><br> |
There was a problem hiding this comment.
We don't need to mention In Spark, NULL values are considered to be lower than any non-NULL values, as it's not related to the user-facing behavior.
| <code>ASC</code> and NULLS sort last if sort order is <code>DESC</code>.<br><br> | ||
| <ol> | ||
| <li> If <code>NULLS FIRST</code> (the default) is specified, then NULL values are returned first | ||
| <li> If <code>NULLS FIRST</code> is specified, then NULL values are returned first |
There was a problem hiding this comment.
the default value depends on the sort order.
| {% highlight sql %} | ||
| [ WITH with_query [ , ... ] ] | ||
| select_statement [ { UNION | INTERSECT | EXCEPT } select_statement, ... ] | ||
| [ ORDER BY { expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [ , ...] } ] |
There was a problem hiding this comment.
according to our g4 file, a query can have multiple SELECT but only one ORDER BY/SORT BY/...
|
Test build #119622 has finished for PR 27866 at commit
|
docs/sql-ref-syntax-qry-select.md
Outdated
| ### Syntax | ||
| {% highlight sql %} | ||
| [ WITH with_query [ , ... ] ] | ||
| select_statement [ { UNION | INTERSECT | EXCEPT } select_statement, ... ] |
There was a problem hiding this comment.
[ ALL | DISTINCT ] seems to be missed while transition.
There was a problem hiding this comment.
It's defined in select_statement: https://github.com/apache/spark/pull/27866/files#diff-bc52347d9c1373190bce4389d3066ad5R40
There was a problem hiding this comment.
Hi, @cloud-fan . They are not the same. I mean UNION ALL, not SELECT ALL.
scala> sql("select 1 union all (select all 1)").show
+---+
| 1|
+---+
| 1|
| 1|
+---+
docs/sql-ref-syntax-qry-select.md
Outdated
| [ WITH with_query [ , ... ] ] | ||
| select_statement [ { UNION | INTERSECT | EXCEPT } select_statement, ... ] | ||
| [ ORDER BY { expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [ , ...] } ] | ||
| [ SORT BY { expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [ , ...] } ] |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM (with two minor comments.)
Thank you, @cloud-fan .
| |Shone S| 16| | ||
| +-------+---+ | ||
|
|
||
| -- A non-foldable expression as an input to limit is not allowed. |
maropu
left a comment
There was a problem hiding this comment.
The change can make the docs cleaner! LGTM except the existing comments.
| <b>Syntax:</b> | ||
| <code> | ||
| ( () | ( expression [ , ... ] ) ) | ||
| ( '()' | ( expression [ , ... ] ) ) |
There was a problem hiding this comment.
The syntax here indicates one group set or more? In above the syntax is GROUP BY [ GROUPING SETS grouping_sets ] group_expression [ , group_expression [ , ... ] ].
For example, group_expression here is for just one group expression.
|
Test build #119646 has finished for PR 27866 at commit
|
|
|
||
| ### Syntax | ||
| {% highlight sql %} | ||
| GROUP BY [ GROUPING SETS grouping_sets ] group_expression [ , group_expression [ , ... ] ] |
There was a problem hiding this comment.
@viirya can you help review this file? thanks!
There was a problem hiding this comment.
Sorry for late. This change LGTM.
|
Test build #119663 has finished for PR 27866 at commit
|
|
@cloud-fan . Please don't forget the following |
|
Test build #119678 has finished for PR 27866 at commit
|
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Merged to master/3.0. Thank you all!
### What changes were proposed in this pull request? A few improvements to the sql ref SELECT doc: 1. correct the syntax of SELECT query 2. correct the default of null sort order 3. correct the GROUP BY syntax 4. several minor fixes ### Why are the changes needed? refine document ### Does this PR introduce any user-facing change? N/A ### How was this patch tested? N/A Closes #27866 from cloud-fan/doc. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 0f0ccda) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
### What changes were proposed in this pull request? A few improvements to the sql ref SELECT doc: 1. correct the syntax of SELECT query 2. correct the default of null sort order 3. correct the GROUP BY syntax 4. several minor fixes ### Why are the changes needed? refine document ### Does this PR introduce any user-facing change? N/A ### How was this patch tested? N/A Closes apache#27866 from cloud-fan/doc. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
What changes were proposed in this pull request?
A few improvements to the sql ref SELECT doc:
Why are the changes needed?
refine document
Does this PR introduce any user-facing change?
N/A
How was this patch tested?
N/A