Skip to content

Commit cca494e

Browse files
committed
Fixing location for extrenal tables
1 parent 4beea9a commit cca494e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ast/ddl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,9 @@ impl fmt::Display for CreateTable {
28032803
if let Some(file_format) = self.file_format {
28042804
write!(f, " STORED AS {file_format}")?;
28052805
}
2806-
write!(f, " LOCATION '{}'", self.location.as_ref().unwrap())?;
2806+
if let Some(location) = &self.location {
2807+
write!(f, " LOCATION '{location}'")?;
2808+
}
28072809
}
28082810

28092811
match &self.table_options {

tests/sqlparser_hive.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ fn parse_table_create() {
3434
let sql = r#"CREATE TABLE IF NOT EXISTS db.table (a BIGINT, b STRING, c TIMESTAMP) PARTITIONED BY (d STRING, e TIMESTAMP) STORED AS ORC LOCATION 's3://...' TBLPROPERTIES ("prop" = "2", "asdf" = '1234', 'asdf' = "1234", "asdf" = 2)"#;
3535
let iof = r#"CREATE TABLE IF NOT EXISTS db.table (a BIGINT, b STRING, c TIMESTAMP) PARTITIONED BY (d STRING, e TIMESTAMP) STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat' LOCATION 's3://...'"#;
3636
let serdeproperties = r#"CREATE EXTERNAL TABLE IF NOT EXISTS db.table (a STRING, b STRING, c STRING) PARTITIONED BY (d STRING, e STRING) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde.config' WITH SERDEPROPERTIES ('prop_a' = 'a', 'prop_b' = 'b') STORED AS TEXTFILE LOCATION 's3://...' TBLPROPERTIES ('prop_c' = 'c')"#;
37+
let externaltable = r#"CREATE EXTERNAL TABLE t (c INT)"#;
3738

3839
hive().verified_stmt(sql);
3940
hive().verified_stmt(iof);
4041
hive().verified_stmt(serdeproperties);
42+
hive().verified_stmt(externaltable);
4143
}
4244

4345
#[test]

0 commit comments

Comments
 (0)