zzzdong commented on code in PR #1732:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1732#discussion_r1962930972
##########
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:
I agree that using OrderByExpr could be a good approach. However, I am
somewhat concerned that users might find it challenging to distinguish between
the different `Expr` when working with it.
--
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]