c2main commented on code in PR #2364:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2364#discussion_r3367241582
##########
tests/sqlparser_postgres.rs:
##########
@@ -9243,3 +9243,43 @@ fn parse_lock_table() {
}
}
}
+
+#[test]
+fn parse_table_command_inheritance_modifiers() {
+ // ONLY (exclude descendants).
+ pg().verified_stmt("TABLE ONLY films");
+ pg().verified_stmt("TABLE ONLY myschema.films");
+ // Trailing * (explicitly include descendants).
+ pg().verified_stmt("TABLE films *");
+ pg().verified_stmt("TABLE myschema.films *");
+ // Parenthesized ONLY — SQL-standard form, canonicalized to parens-less.
+ pg().one_statement_parses_to("TABLE ONLY (films)", "TABLE ONLY films");
+ // Inheritance modifiers are usable in all contexts the TABLE command is.
+ pg().verified_stmt("CREATE TABLE new_t AS TABLE ONLY old_t");
+ pg().verified_stmt("CREATE TABLE new_t AS TABLE old_t *");
+ pg().verified_stmt("CREATE VIEW v AS TABLE ONLY films");
+ pg().verified_stmt("SELECT * FROM (TABLE ONLY films) AS x");
+}
+
+#[test]
+fn parse_table_command_rejects_invalid() {
+ // Inheritance modifiers are mutually exclusive.
+ assert!(
+ pg().parse_sql_statements("TABLE ONLY films *").is_err(),
+ "expected PG parser to reject: TABLE ONLY films *"
+ );
+
+ for sql in [
+ "TABLE films WHERE x > 0",
Review Comment:
might be interesting to test: `TABLE db.schema.table` is rejected.
--
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]