iffyio commented on code in PR #1604: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1604#discussion_r1895636641
########## src/ast/query.rs: ########## @@ -2790,3 +2790,14 @@ impl fmt::Display for ValueTableMode { } } } + +/// The update table from options Review Comment: ```suggestion /// The `FROM` clause of an `UPDATE TABLE` statement ``` ########## tests/sqlparser_common.rs: ########## @@ -12577,9 +12577,20 @@ fn overflow() { let statement = statements.pop().unwrap(); assert_eq!(statement.to_string(), sql); } - #[test] fn parse_select_without_projection() { let dialects = all_dialects_where(|d| d.supports_empty_projections()); dialects.verified_stmt("SELECT FROM users"); } + +#[test] +fn parse_update_from_before_select() { + all_dialects() + .verified_stmt("UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name WHERE t1.id = t2.id"); + + let res = all_dialects().parse_sql_statements( + "UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name FROM (SELECT name from t2) AS t2", + ); + + assert!(res.is_err()); Review Comment: could we assert in [this style](https://github.com/apache/datafusion-sqlparser-rs/blob/6cdf66457006a3fbfc569dc262e78f404522821b/tests/sqlparser_common.rs#L219-L235) to expect a specific error message? ########## src/ast/query.rs: ########## @@ -2790,3 +2790,14 @@ impl fmt::Display for ValueTableMode { } } } + +/// The update table from options +#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))] +pub enum UpdateTableFromKind { + /// Table sample located before the table alias option + BeforeSet(TableWithJoins), + /// Table sample located after the table alias option + AfterSet(TableWithJoins), Review Comment: Could we include example sql with each variant? thinking that would help folks differentiate easily. Also the descriptions sound incorrect to be referencing table sample/alias? ########## src/keywords.rs: ########## @@ -941,6 +941,7 @@ pub const RESERVED_FOR_TABLE_ALIAS: &[Keyword] = &[ // Reserved for Snowflake table sample Keyword::SAMPLE, Keyword::TABLESAMPLE, + Keyword::FROM, Review Comment: is this change related to the PR (wasn't clear to me if so)? -- 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