PokIsemaine commented on code in PR #1724:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1724#discussion_r1955495623


##########
src/ast/query.rs:
##########
@@ -2205,31 +2205,50 @@ pub enum JoinConstraint {
 #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
-pub struct OrderBy {
-    pub exprs: Vec<OrderByExpr>,
-    /// Optional: `INTERPOLATE`
-    /// Supported by [ClickHouse syntax]
+pub enum OrderBy {
+    /// ALL syntax of [DuckDB] and [ClickHouse].
     ///
-    /// [ClickHouse syntax]: 
<https://clickhouse.com/docs/en/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier>
-    pub interpolate: Option<Interpolate>,
+    /// [DuckDB]:  <https://duckdb.org/docs/sql/query_syntax/orderby>
+    /// [ClickHouse]: 
<https://clickhouse.com/docs/en/sql-reference/statements/select/order-by>
+    All(OrderByAll),
+
+    /// Expressions
+    Expressions(OrderByExprsWithInterpolate),
 }
 
 impl fmt::Display for OrderBy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "ORDER BY")?;
-        if !self.exprs.is_empty() {
-            write!(f, " {}", display_comma_separated(&self.exprs))?;
-        }
-        if let Some(ref interpolate) = self.interpolate {
-            match &interpolate.exprs {
-                Some(exprs) => write!(f, " INTERPOLATE ({})", 
display_comma_separated(exprs))?,
-                None => write!(f, " INTERPOLATE")?,
+        match self {
+            OrderBy::Expressions(exprs) => {
+                write!(f, "{}", exprs)?;
+            }
+            OrderBy::All(all) => {
+                write!(f, " ALL{}", all)?;
             }
         }
+
         Ok(())
     }
 }
 
+impl OrderBy {
+    pub fn get_exprs(&self) -> Option<&Vec<OrderByExpr>> {
+        match self {
+            OrderBy::Expressions(exprs_with_interpolate) => 
Some(&exprs_with_interpolate.exprs),
+            OrderBy::All(_) => None,
+        }
+    }
+    pub fn get_interpolate(&self) -> Option<&Interpolate> {
+        match self {
+            OrderBy::Expressions(exprs_with_interpolate) => {
+                exprs_with_interpolate.interpolate.as_ref()
+            }
+            OrderBy::All(_) => None,
+        }
+    }
+}

Review Comment:
   Yes, this is mainly for testing, thank you for your suggestion.



-- 
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: github-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to