Skip to content

Commit 111c0ce

Browse files
osipovartemDenys Tsomenko
authored andcommitted
Skip CREATE STAGE by DFParser (pass to dialect parser) (#11)
* DFParser should skip unsupported COPY INTO * Add tests * Add tests * Add tests * Add tests * Fmt * Fmt * Fmt
1 parent 1f519a1 commit 111c0ce

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

datafusion/sql/src/parser.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,11 @@ impl<'a> DFParser<'a> {
701701
self.parser.expect_keyword(Keyword::EXTERNAL)?;
702702
self.parse_create_external_table(true)
703703
} else {
704-
Ok(Statement::Statement(Box::from(self.parser.parse_create()?)))
704+
// Push back CREATE
705+
self.parser.prev_token();
706+
Ok(Statement::Statement(Box::from(
707+
self.parser.parse_statement()?,
708+
)))
705709
}
706710
}
707711

@@ -1065,6 +1069,26 @@ mod tests {
10651069
}
10661070
}
10671071

1072+
#[test]
1073+
fn skip_create_stage_snowflake() -> Result<(), ParserError> {
1074+
let sql =
1075+
"CREATE OR REPLACE STAGE stage URL='s3://data.csv' FILE_FORMAT=(TYPE=csv)";
1076+
let dialect = Box::new(SnowflakeDialect);
1077+
let statements = DFParser::parse_sql_with_dialect(sql, dialect.as_ref())?;
1078+
1079+
assert_eq!(
1080+
statements.len(),
1081+
1,
1082+
"Expected to parse exactly one statement"
1083+
);
1084+
match &statements[0] {
1085+
Statement::Statement(stmt) => {
1086+
assert_eq!(stmt.to_string(), sql);
1087+
}
1088+
_ => panic!("Expected statement type"),
1089+
}
1090+
Ok(())
1091+
}
10681092
#[test]
10691093
fn create_external_table() -> Result<(), DataFusionError> {
10701094
// positive case

0 commit comments

Comments
 (0)