okumin commented on code in PR #4511:
URL: https://github.com/apache/hive/pull/4511#discussion_r1274902625


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -11258,38 +11259,47 @@ private Operator genPostGroupByBodyPlan(Operator 
curr, String dest, QB qb,
 
     if (qbp.getOrderByForClause(dest) != null) {
       genReduceSink = true;
+      numReducers = 1;
       hasOrderBy = true;
     }
 
+    if (offset > 0 && !hasOrderBy) {
+      HiveConf.StrictChecks.checkOffsetWithoutOrderBy(conf);
+
+      assert limit != null : "OFFSET is always paired with LIMIT";

Review Comment:
   I don't have immediate access to the standard and MySQL is the only one I 
found so far.
   
   Trino 413.
   
   ```
   trino> SELECT * FROM tpcds.tiny.item OFFSET 10;                              
                      
   ```
   
   Spark 3.4.1.
   
   ```
   spark-sql (default)> SELECT * FROM item OFFSET 1990;     
   ```
   
   MySQL 8.
   
   ```
   mysql> SELECT * FROM item OFFSET 2;
   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use near 
'2' at line 1
   ```
   
   I guess we can support it by updating the grammar and steps related to 
OFFSET.
   
   
https://github.com/apache/hive/blob/rel/release-4.0.0-alpha-2/parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g#L2779-L2785



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to