Skip to content

Commit f75b8ba

Browse files
committed
Make TextFormat case insensitive
1 parent f4fbd9b commit f75b8ba

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ impl Parser {
10061006
let table_name = self.parse_object_name()?;
10071007
let (columns, constraints) = self.parse_columns()?;
10081008
self.expect_keywords(&[Keyword::STORED, Keyword::AS])?;
1009-
let file_format = self.parse_identifier()?.value.parse::<FileFormat>()?;
1009+
let file_format = self.parse_identifier()?.value.to_ascii_uppercase().parse::<FileFormat>()?;
10101010

10111011
self.expect_keyword(Keyword::LOCATION)?;
10121012
let location = self.parse_literal_string()?;

tests/sqlparser_common.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,24 @@ fn parse_create_external_table() {
12891289
}
12901290
}
12911291

1292+
#[test]
1293+
fn parse_create_external_table_lowercase() {
1294+
let sql = "create external table uk_cities (\
1295+
name varchar(100) not null,\
1296+
lat double null,\
1297+
lng double)\
1298+
stored as parquet location '/tmp/example.csv'";
1299+
let ast = one_statement_parses_to(
1300+
sql,
1301+
"CREATE EXTERNAL TABLE uk_cities (\
1302+
name character varying(100) NOT NULL, \
1303+
lat double NULL, \
1304+
lng double) \
1305+
STORED AS PARQUET LOCATION '/tmp/example.csv'",
1306+
);
1307+
assert_matches!(ast, Statement::CreateTable{..});
1308+
}
1309+
12921310
#[test]
12931311
fn parse_create_table_empty() {
12941312
// Zero-column tables are weird, but supported by at least PostgreSQL.

0 commit comments

Comments
 (0)