Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11176,6 +11176,7 @@ impl<'a> Parser<'a> {
Keyword::BZIP2,
Keyword::CLEANPATH,
Keyword::COMPUPDATE,
Keyword::CREDENTIALS,
Keyword::CSV,
Keyword::DATEFORMAT,
Keyword::DELIMITER,
Expand Down Expand Up @@ -11233,6 +11234,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) =
Expand Down
7 changes: 7 additions & 0 deletions tests/sqlparser_redshift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
}