Skip to content

Commit 420471e

Browse files
committed
Fix parsing CREDENTIALS keyword for redshift
1 parent 1da2ff7 commit 420471e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/ast/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9217,6 +9217,9 @@ pub enum CopyLegacyOption {
92179217
TruncateColumns,
92189218
/// ZSTD
92199219
Zstd,
9220+
/// Redshift `CREDENTIALS 'auth-args'`
9221+
/// <https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-authorization.html>
9222+
Credentials(String),
92209223
}
92219224

92229225
impl fmt::Display for CopyLegacyOption {
@@ -9327,6 +9330,7 @@ impl fmt::Display for CopyLegacyOption {
93279330
}
93289331
TruncateColumns => write!(f, "TRUNCATECOLUMNS"),
93299332
Zstd => write!(f, "ZSTD"),
9333+
Credentials(s) => write!(f, "CREDENTIALS '{}'", value::escape_single_quote_string(s)),
93309334
}
93319335
}
93329336
}

src/parser/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11176,6 +11176,7 @@ impl<'a> Parser<'a> {
1117611176
Keyword::BZIP2,
1117711177
Keyword::CLEANPATH,
1117811178
Keyword::COMPUPDATE,
11179+
Keyword::CREDENTIALS,
1117911180
Keyword::CSV,
1118011181
Keyword::DATEFORMAT,
1118111182
Keyword::DELIMITER,
@@ -11233,6 +11234,9 @@ impl<'a> Parser<'a> {
1123311234
};
1123411235
CopyLegacyOption::CompUpdate { preset, enabled }
1123511236
}
11237+
Some(Keyword::CREDENTIALS) => {
11238+
CopyLegacyOption::Credentials(self.parse_literal_string()?)
11239+
}
1123611240
Some(Keyword::CSV) => CopyLegacyOption::Csv({
1123711241
let mut opts = vec![];
1123811242
while let Some(opt) =

tests/sqlparser_redshift.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,10 @@ fn test_create_table_diststyle() {
467467
redshift().verified_stmt("CREATE TABLE t1 (c1 INT) DISTSTYLE KEY DISTKEY(c1)");
468468
redshift().verified_stmt("CREATE TABLE t1 (c1 INT) DISTSTYLE ALL");
469469
}
470+
471+
#[test]
472+
fn test_copy_credentials() {
473+
redshift().verified_stmt(
474+
"COPY t1 FROM 's3://bucket/file.csv' CREDENTIALS 'aws_access_key_id=AK;aws_secret_access_key=SK' CSV",
475+
);
476+
}

0 commit comments

Comments
 (0)