mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-26 15:39:12 +00:00
Make FileFormat case insensitive (#200)
This commit is contained in:
parent
a0f076acda
commit
68afa2a764
2 changed files with 24 additions and 1 deletions
|
@ -1006,7 +1006,12 @@ impl Parser {
|
||||||
let table_name = self.parse_object_name()?;
|
let table_name = self.parse_object_name()?;
|
||||||
let (columns, constraints) = self.parse_columns()?;
|
let (columns, constraints) = self.parse_columns()?;
|
||||||
self.expect_keywords(&[Keyword::STORED, Keyword::AS])?;
|
self.expect_keywords(&[Keyword::STORED, Keyword::AS])?;
|
||||||
let file_format = self.parse_identifier()?.value.parse::<FileFormat>()?;
|
// We probably shouldn't parse the file format as an identifier..
|
||||||
|
let file_format = self
|
||||||
|
.parse_identifier()?
|
||||||
|
.value
|
||||||
|
.to_ascii_uppercase()
|
||||||
|
.parse::<FileFormat>()?;
|
||||||
|
|
||||||
self.expect_keyword(Keyword::LOCATION)?;
|
self.expect_keyword(Keyword::LOCATION)?;
|
||||||
let location = self.parse_literal_string()?;
|
let location = self.parse_literal_string()?;
|
||||||
|
|
|
@ -1289,6 +1289,24 @@ fn parse_create_external_table() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_create_external_table_lowercase() {
|
||||||
|
let sql = "create external table uk_cities (\
|
||||||
|
name varchar(100) not null,\
|
||||||
|
lat double null,\
|
||||||
|
lng double)\
|
||||||
|
stored as parquet location '/tmp/example.csv'";
|
||||||
|
let ast = one_statement_parses_to(
|
||||||
|
sql,
|
||||||
|
"CREATE EXTERNAL TABLE uk_cities (\
|
||||||
|
name character varying(100) NOT NULL, \
|
||||||
|
lat double NULL, \
|
||||||
|
lng double) \
|
||||||
|
STORED AS PARQUET LOCATION '/tmp/example.csv'",
|
||||||
|
);
|
||||||
|
assert_matches!(ast, Statement::CreateTable{..});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_create_table_empty() {
|
fn parse_create_table_empty() {
|
||||||
// Zero-column tables are weird, but supported by at least PostgreSQL.
|
// Zero-column tables are weird, but supported by at least PostgreSQL.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue