Skip to content

Commit d052db1

Browse files
committed
Merge branch 'main' into mysql-users
2 parents 7f1ff61 + 687ce2d commit d052db1

23 files changed

+790
-160
lines changed

src/ast/ddl.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,26 @@ impl fmt::Display for ReferentialAction {
17861786
}
17871787
}
17881788

1789+
/// `<drop behavior> ::= CASCADE | RESTRICT`.
1790+
///
1791+
/// Used in `DROP` statements.
1792+
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
1793+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
1794+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
1795+
pub enum DropBehavior {
1796+
Restrict,
1797+
Cascade,
1798+
}
1799+
1800+
impl fmt::Display for DropBehavior {
1801+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1802+
f.write_str(match self {
1803+
DropBehavior::Restrict => "RESTRICT",
1804+
DropBehavior::Cascade => "CASCADE",
1805+
})
1806+
}
1807+
}
1808+
17891809
/// SQL user defined type definition
17901810
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
17911811
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

src/ast/dml.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use sqlparser_derive::{Visit, VisitMut};
3232
pub use super::ddl::{ColumnDef, TableConstraint};
3333

3434
use super::{
35-
display_comma_separated, display_separated, ClusteredBy, CommentDef, Expr, FileFormat,
36-
FromTable, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident,
35+
display_comma_separated, display_separated, Assignment, ClusteredBy, CommentDef, Expr,
36+
FileFormat, FromTable, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident,
3737
InsertAliases, MysqlInsertPriority, ObjectName, OnCommit, OnInsert, OneOrManyWithParens,
3838
OrderByExpr, Query, RowAccessPolicy, SelectItem, SqlOption, SqliteOnConflict, TableEngine,
3939
TableWithJoins, Tag, WrappedCollection,
@@ -480,6 +480,9 @@ pub struct Insert {
480480
pub overwrite: bool,
481481
/// A SQL query that specifies what to insert
482482
pub source: Option<Box<Query>>,
483+
/// MySQL `INSERT INTO ... SET`
484+
/// See: <https://dev.mysql.com/doc/refman/8.4/en/insert.html>
485+
pub assignments: Vec<Assignment>,
483486
/// partitioned insert (Hive)
484487
pub partitioned: Option<Vec<Expr>>,
485488
/// Columns defined after PARTITION
@@ -545,9 +548,10 @@ impl Display for Insert {
545548

546549
if let Some(source) = &self.source {
547550
write!(f, "{source}")?;
548-
}
549-
550-
if self.source.is_none() && self.columns.is_empty() {
551+
} else if !self.assignments.is_empty() {
552+
write!(f, "SET ")?;
553+
write!(f, "{}", display_comma_separated(&self.assignments))?;
554+
} else if self.source.is_none() && self.columns.is_empty() {
551555
write!(f, "DEFAULT VALUES")?;
552556
}
553557

src/ast/helpers/stmt_create_table.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,11 @@ mod tests {
548548

549549
#[test]
550550
pub fn test_from_invalid_statement() {
551-
let stmt = Statement::Commit { chain: false };
551+
let stmt = Statement::Commit {
552+
chain: false,
553+
end: false,
554+
modifier: None,
555+
};
552556

553557
assert_eq!(
554558
CreateTableBuilder::try_from(stmt).unwrap_err(),

src/ast/helpers/stmt_data_loading.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use core::fmt::Formatter;
2929
#[cfg(feature = "serde")]
3030
use serde::{Deserialize, Serialize};
3131

32-
use crate::ast::Ident;
32+
use crate::ast::{Ident, ObjectName};
3333
#[cfg(feature = "visitor")]
3434
use sqlparser_derive::{Visit, VisitMut};
3535

@@ -156,3 +156,22 @@ impl fmt::Display for StageLoadSelectItem {
156156
Ok(())
157157
}
158158
}
159+
160+
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
161+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
162+
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
163+
pub struct FileStagingCommand {
164+
#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
165+
pub stage: ObjectName,
166+
pub pattern: Option<String>,
167+
}
168+
169+
impl fmt::Display for FileStagingCommand {
170+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
171+
write!(f, "{}", self.stage)?;
172+
if let Some(pattern) = self.pattern.as_ref() {
173+
write!(f, " PATTERN='{pattern}'")?;
174+
}
175+
Ok(())
176+
}
177+
}

0 commit comments

Comments
 (0)