zzzdong commented on code in PR #1732:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1732#discussion_r1966963134


##########
src/ast/mod.rs:
##########
@@ -8591,6 +8591,61 @@ pub enum CopyIntoSnowflakeKind {
     Location,
 }
 
+/// Index Field
+///
+/// This structure used here [`MySQL` CREATE INDEX][1], [`PostgreSQL` CREATE 
INDEX][2], [`MySQL` CREATE TABLE][3].
+///
+/// [1]: https://dev.mysql.com/doc/refman/8.3/en/create-index.html
+/// [2]: https://www.postgresql.org/docs/17/sql-createindex.html
+/// [3]: https://dev.mysql.com/doc/refman/8.3/en/create-table.html
+
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct IndexField {
+    pub expr: IndexExpr,
+    /// Optional `ASC` or `DESC`
+    pub asc: Option<bool>,
+}
+
+impl fmt::Display for IndexField {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}", self.expr)?;
+        match self.asc {
+            Some(true) => write!(f, " ASC")?,
+            Some(false) => write!(f, " DESC")?,
+            None => (),
+        }
+        Ok(())
+    }
+}
+
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub enum IndexExpr {
+    Column(Ident),
+    /// Mysql specific syntax
+    ///
+    /// See [Mysql 
documentation](https://dev.mysql.com/doc/refman/8.3/en/create-index.html)
+    /// for more details.
+    ColumnPrefix {
+        column: Ident,
+        length: u64,
+    },
+    Functional(Box<Expr>),
+}

Review Comment:
   That's right. I believe adding only ColumnPrefix will suffice. We can extend 
the Expr enum as follows:
   
   ```rust
   enum Expr {
       ColumnPrefix { column: Ident, length: u64 }
   }
   ```



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