spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] srowen commented on a change in pull request #27288: [SPARK-30579][DOC] Document ORDER BY Clause of SELECT statement in SQL Reference
Date Wed, 22 Jan 2020 14:57:53 GMT
srowen commented on a change in pull request #27288: [SPARK-30579][DOC] Document ORDER BY Clause
of SELECT statement in SQL Reference
URL: https://github.com/apache/spark/pull/27288#discussion_r369608987
 
 

 ##########
 File path: docs/sql-ref-syntax-qry-select-orderby.md
 ##########
 @@ -18,5 +18,121 @@ license: |
   See the License for the specific language governing permissions and
   limitations under the License.
 ---
+The <code>ORDER BY</code> clause is used to return the result rows in a sorted
manner
+in the user specified order. Unlike the <code>SORT BY</code> clause, this clause
guarantees
+total order in the output. 
 
-**This page is under construction**
+### Syntax
+{% highlight sql %}
+ORDER BY { expression [ sort_direction | nulls_sort_oder ] [ , ...] }
+{% endhighlight %}
+
+### Parameters
+<dl>
+  <dt><code><em>ORDER BY</em></code></dt>
+  <dd>
+    Specifies a comma-separated list of expressions along with optional parameters <code>sort_direction</code>
+    and <code>nulls_sort_order</code> which are used to sort the rows.
+  </dd>
+  <dt><code><em>sort_direction</em></code></dt>
+  <dd>
+    Optionally specifies whether to sort the rows in ascending (lowest to highest) or descending
+    (highest to lowest) order. The valid values for sort direction are <code>ASC</code>
for ascending
+    and <code>DESC</code> for descending. If sort direction is not explicitly
specified then by default
+    rows are sorted in ascending manner. <br><br>
+    <b>Syntax:</b>
+    <code>
+       [ ASC | DESC ]
+    </code>
+  </dd>
+  <dt><code><em>nulls_sort_order</em></code></dt>
+  <dd>
+    Optionally specifies whether NULL values are returned before/after non-NULL values, based
on the 
+    sort direction. In Spark, NULL values are considered to be lower than any non-NULL values
by default.
+    Therefore the ordering of NULL values depend on the sort direction.<br><br>
+    <ol>
+      <li>If the sort order is ASC, NULLS are returned first; to force NULLS to be
last, use NULLS LAST</li>
 
 Review comment:
   I might turn this around, to emphasize the null sort order: "If `NULLS FIRST` (the default),
then NULLs are returned first if sort order is `ASC`, and last if sort order is `DESC`" and
likewise for the second items.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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


Mime
View raw message