iffyio commented on code in PR #2245:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2245#discussion_r2872017426
##########
tests/sqlparser_postgres.rs:
##########
@@ -1084,6 +1084,61 @@ PHP ₱ USD $
pg_and_generic().one_statement_parses_to(sql, "");
}
+#[test]
+fn parse_copy_from_stdin_without_semicolon() {
+ let stmt = pg().verified_stmt("COPY bitwise_test FROM STDIN NULL 'null'");
+ assert_eq!(
+ stmt,
+ Statement::Copy {
+ source: CopySource::Table {
+ table_name: ObjectName::from(vec!["bitwise_test".into()]),
+ columns: vec![],
+ },
+ to: false,
+ target: CopyTarget::Stdin,
+ options: vec![],
+ legacy_options: vec![CopyLegacyOption::Null("null".into())],
+ values: vec![],
+ }
+ );
+}
+
+#[test]
+fn parse_copy_from_stdin_without_semicolon_variants() {
+ let cases = [
+ "COPY bool_test FROM STDIN NULL 'null'",
+ "COPY varbit_table FROM stdin",
+ "COPY bit_table FROM stdin",
+ "copy copytest2(test) from stdin",
+ "copy copytest3 from stdin csv header",
+ "copy copytest4 from stdin (header)",
+ "copy parted_copytest from stdin",
+ "copy tab_progress_reporting from stdin",
+ "copy oversized_column_default from stdin",
+ "COPY x (a, b, c, d, e) from stdin",
+ "copy header_copytest (c, a) from stdin",
+ "COPY atest5 (two) FROM stdin",
+ "COPY main_table (a, b) FROM stdin",
+ ];
+
+ for sql in cases {
+ match pg().one_statement_parses_to(sql, "") {
Review Comment:
can this test use `verified_stmt` instead? Also, what's the difference
between this test and `parse_copy_from_stdin_without_semicolon`?
##########
src/parser/mod.rs:
##########
@@ -11028,8 +11028,12 @@ impl<'a> Parser<'a> {
legacy_options.push(opt);
}
let values = if let CopyTarget::Stdin = target {
- self.expect_token(&Token::SemiColon)?;
- self.parse_tsv()
+ if self.peek_token_ref().token == Token::EOF {
Review Comment:
can this be collapsed to `if let copy && self.peek_token() != EOF`?
--
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]