Skip to content

Always wrap statement in a named struct #1204

Open
@tisonkun

Description

@tisonkun

In GreptimeDB, we write code like:

#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut)]
pub struct Delete {
    // Can only be sqlparser::ast::Statement::Delete variant
    pub inner: Statement,
}

It's because in sqlparser-rs, these statement variants are unnamed struct:

    Delete {
        /// Multi tables delete are supported in mysql
        tables: Vec<ObjectName>,
        /// FROM
        from: Vec<TableWithJoins>,
        /// USING (Snowflake, Postgres, MySQL)
        using: Option<Vec<TableWithJoins>>,
        /// WHERE
        selection: Option<Expr>,
        /// RETURNING
        returning: Option<Vec<SelectItem>>,
    },

I wonder if we can always wrap statement in a named struct so that downstream software can reuse the AST and impls (like for Display) more smoothly.

I don't know if it's a breaking change or we're generally OK with this.

Ref - GreptimeTeam/greptimedb#3646

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions