This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch gh-readonly-queue/main/pr-2262-915448cf335863da73dee8e3fe0e3275189d703c in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit 6691f31b753708bd5952cc453b65440d7177a9bb Author: Andriy Romanov <[email protected]> AuthorDate: Wed Mar 4 05:48:33 2026 -0800 Fix credentials parsing for redshift (#2262) --- src/ast/mod.rs | 4 ++++ src/parser/mod.rs | 4 ++++ tests/sqlparser_redshift.rs | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 6a2f9bd9..e201f784 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -9217,6 +9217,9 @@ pub enum CopyLegacyOption { TruncateColumns, /// ZSTD Zstd, + /// Redshift `CREDENTIALS 'auth-args'` + /// <https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-authorization.html> + Credentials(String), } impl fmt::Display for CopyLegacyOption { @@ -9327,6 +9330,7 @@ impl fmt::Display for CopyLegacyOption { } TruncateColumns => write!(f, "TRUNCATECOLUMNS"), Zstd => write!(f, "ZSTD"), + Credentials(s) => write!(f, "CREDENTIALS '{}'", value::escape_single_quote_string(s)), } } } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 688d1d02..75b5bfa7 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -11177,6 +11177,7 @@ impl<'a> Parser<'a> { Keyword::BZIP2, Keyword::CLEANPATH, Keyword::COMPUPDATE, + Keyword::CREDENTIALS, Keyword::CSV, Keyword::DATEFORMAT, Keyword::DELIMITER, @@ -11234,6 +11235,9 @@ impl<'a> Parser<'a> { }; CopyLegacyOption::CompUpdate { preset, enabled } } + Some(Keyword::CREDENTIALS) => { + CopyLegacyOption::Credentials(self.parse_literal_string()?) + } Some(Keyword::CSV) => CopyLegacyOption::Csv({ let mut opts = vec![]; while let Some(opt) = diff --git a/tests/sqlparser_redshift.rs b/tests/sqlparser_redshift.rs index 03dfda2c..243b0646 100644 --- a/tests/sqlparser_redshift.rs +++ b/tests/sqlparser_redshift.rs @@ -467,3 +467,10 @@ fn test_create_table_diststyle() { redshift().verified_stmt("CREATE TABLE t1 (c1 INT) DISTSTYLE KEY DISTKEY(c1)"); redshift().verified_stmt("CREATE TABLE t1 (c1 INT) DISTSTYLE ALL"); } + +#[test] +fn test_copy_credentials() { + redshift().verified_stmt( + "COPY t1 FROM 's3://bucket/file.csv' CREDENTIALS 'aws_access_key_id=AK;aws_secret_access_key=SK' CSV", + ); +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
