You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "beliefer (via GitHub)" <gi...@apache.org> on 2023/05/12 03:45:14 UTC

[GitHub] [spark] beliefer opened a new pull request, #41151: [SPARK-43483][SQL][DOC] Adds SQL references for OFFSET clause.

beliefer opened a new pull request, #41151:
URL: https://github.com/apache/spark/pull/41151

   ### What changes were proposed in this pull request?
   Spark 3.4.0 released the new syntax: `OFFSET clause`.
   But the SQL reference missing the description for it.
   
   
   ### Why are the changes needed?
   Adds SQL reference for `OFFSET` clause.
   
   ### Does this PR introduce _any_ user-facing change?
   'Yes'.
   Users could find out the SQL reference for `OFFSET` clause.
   
   
   ### How was this patch tested?
   Manual verify.
   


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] beliefer commented on pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.

Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #41151:
URL: https://github.com/apache/spark/pull/41151#issuecomment-1547096505

   ping @cloud-fan 


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] cloud-fan commented on a diff in pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #41151:
URL: https://github.com/apache/spark/pull/41151#discussion_r1193569941


##########
docs/sql-ref-syntax-qry-select-limit.md:
##########
@@ -91,7 +91,21 @@ SELECT name, age FROM person ORDER BY name LIMIT length('SPARK');
 
 -- A non-foldable expression as an input to LIMIT is not allowed.
 SELECT name, age FROM person ORDER BY name LIMIT length(name);
-org.apache.spark.sql.AnalysisException: The limit expression must evaluate to a constant value ...
+org.apache.spark.sql.AnalysisException
+{
+  "errorClass" : "_LEGACY_ERROR_TEMP_2400",

Review Comment:
   BTW, is this really what the end users will see?



##########
docs/sql-ref-syntax-qry-select-limit.md:
##########
@@ -91,7 +91,21 @@ SELECT name, age FROM person ORDER BY name LIMIT length('SPARK');
 
 -- A non-foldable expression as an input to LIMIT is not allowed.
 SELECT name, age FROM person ORDER BY name LIMIT length(name);
-org.apache.spark.sql.AnalysisException: The limit expression must evaluate to a constant value ...
+org.apache.spark.sql.AnalysisException
+{
+  "errorClass" : "_LEGACY_ERROR_TEMP_2400",

Review Comment:
   BTW, is this really what the end users will see? A JSON string?



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] cloud-fan closed pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.
URL: https://github.com/apache/spark/pull/41151


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] beliefer commented on pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.

Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on PR #41151:
URL: https://github.com/apache/spark/pull/41151#issuecomment-1548874149

   @cloud-fan @HyukjinKwon Thank you for all!


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] cloud-fan commented on pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #41151:
URL: https://github.com/apache/spark/pull/41151#issuecomment-1547787139

   thanks, merging to master/3.4!


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [spark] cloud-fan commented on a diff in pull request #41151: [SPARK-43483][SQL][DOCS] Adds SQL references for OFFSET clause.

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #41151:
URL: https://github.com/apache/spark/pull/41151#discussion_r1193569101


##########
docs/sql-ref-syntax-qry-select-limit.md:
##########
@@ -91,7 +91,21 @@ SELECT name, age FROM person ORDER BY name LIMIT length('SPARK');
 
 -- A non-foldable expression as an input to LIMIT is not allowed.
 SELECT name, age FROM person ORDER BY name LIMIT length(name);
-org.apache.spark.sql.AnalysisException: The limit expression must evaluate to a constant value ...
+org.apache.spark.sql.AnalysisException
+{
+  "errorClass" : "_LEGACY_ERROR_TEMP_2400",

Review Comment:
   since we are documenting this error, can we assign an official error class name to it?



##########
docs/sql-ref-syntax-qry-select-offset.md:
##########
@@ -0,0 +1,115 @@
+---
+layout: global
+title: OFFSET Clause
+displayTitle: OFFSET Clause
+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
+
+The `OFFSET` clause is used to specify the number of rows to skip before beginning to return rows
+returned by the [SELECT](sql-ref-syntax-qry-select.html) statement. In general, this clause
+is used in conjunction with [ORDER BY](sql-ref-syntax-qry-select-orderby.html) to
+ensure that the results are deterministic.
+
+### Syntax
+
+```sql
+OFFSET integer_expression
+```
+
+### Parameters
+
+* **integer_expression**
+
+    Specifies a foldable expression that returns an integer.
+
+### Examples
+
+```sql
+CREATE TABLE person (name STRING, age INT);
+INSERT INTO person VALUES
+    ('Zen Hui', 25),
+    ('Anil B', 18),
+    ('Shone S', 16),
+    ('Mike A', 25),
+    ('John A', 18),
+    ('Jack N', 16);
+
+-- Skip the first two rows.
+SELECT name, age FROM person ORDER BY name OFFSET 2;
++-------+---+
+|   name|age|
++-------+---+
+| John A| 18|
+| Mike A| 25|
+|Shone S| 16|
+|Zen Hui| 25|
++-------+---+
+
+-- Skip the first two rows and returns the next three rows.
+SELECT name, age FROM person ORDER BY name LIMIT 3 OFFSET 2;
++-------+---+
+|   name|age|
++-------+---+
+| John A| 18|
+| Mike A| 25|
+|Shone S| 16|
++-------+---+
+
+-- A function expression as an input to OFFSET.
+SELECT name, age FROM person ORDER BY name OFFSET length('SPARK');
++-------+---+
+|   name|age|
++-------+---+
+|Zen Hui| 25|
++-------+---+
+
+-- A non-foldable expression as an input to OFFSET is not allowed.
+SELECT name, age FROM person ORDER BY name OFFSET length(name);
+org.apache.spark.sql.AnalysisException

Review Comment:
   ditto



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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