mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 01:15:00 +00:00
Support "with" identifiers surrounded by backticks in GenericDialect
(#1010)
This commit is contained in:
parent
57090537f0
commit
9832adb376
2 changed files with 17 additions and 8 deletions
|
@ -95,7 +95,7 @@ pub trait Dialect: Debug + Any {
|
||||||
/// MySQL, MS SQL, and sqlite). You can accept one of characters listed
|
/// MySQL, MS SQL, and sqlite). You can accept one of characters listed
|
||||||
/// in `Word::matching_end_quote` here
|
/// in `Word::matching_end_quote` here
|
||||||
fn is_delimited_identifier_start(&self, ch: char) -> bool {
|
fn is_delimited_identifier_start(&self, ch: char) -> bool {
|
||||||
ch == '"'
|
ch == '"' || ch == '`'
|
||||||
}
|
}
|
||||||
/// Determine if quoted characters are proper for identifier
|
/// Determine if quoted characters are proper for identifier
|
||||||
fn is_proper_identifier_inside_quotes(&self, mut _chars: Peekable<Chars<'_>>) -> bool {
|
fn is_proper_identifier_inside_quotes(&self, mut _chars: Peekable<Chars<'_>>) -> bool {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use sqlparser::ast::{
|
||||||
SelectItem, Statement, TableFactor, UnaryOperator, Value,
|
SelectItem, Statement, TableFactor, UnaryOperator, Value,
|
||||||
};
|
};
|
||||||
use sqlparser::dialect::{GenericDialect, HiveDialect};
|
use sqlparser::dialect::{GenericDialect, HiveDialect};
|
||||||
use sqlparser::parser::ParserError;
|
use sqlparser::parser::{ParserError, ParserOptions};
|
||||||
use sqlparser::test_utils::*;
|
use sqlparser::test_utils::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -32,6 +32,20 @@ fn parse_table_create() {
|
||||||
hive().verified_stmt(iof);
|
hive().verified_stmt(iof);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generic(options: Option<ParserOptions>) -> TestedDialects {
|
||||||
|
TestedDialects {
|
||||||
|
dialects: vec![Box::new(GenericDialect {})],
|
||||||
|
options,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_describe() {
|
||||||
|
let describe = r#"DESCRIBE namespace.`table`"#;
|
||||||
|
hive().verified_stmt(describe);
|
||||||
|
generic(None).verified_stmt(describe);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_insert_overwrite() {
|
fn parse_insert_overwrite() {
|
||||||
let insert_partitions = r#"INSERT OVERWRITE TABLE db.new_table PARTITION (a = '1', b) SELECT a, b, c FROM db.table"#;
|
let insert_partitions = r#"INSERT OVERWRITE TABLE db.new_table PARTITION (a = '1', b) SELECT a, b, c FROM db.table"#;
|
||||||
|
@ -265,13 +279,8 @@ fn parse_create_function() {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let generic = TestedDialects {
|
|
||||||
dialects: vec![Box::new(GenericDialect {})],
|
|
||||||
options: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
generic.parse_sql_statements(sql).unwrap_err(),
|
generic(None).parse_sql_statements(sql).unwrap_err(),
|
||||||
ParserError::ParserError(
|
ParserError::ParserError(
|
||||||
"Expected an object type after CREATE, found: FUNCTION".to_string()
|
"Expected an object type after CREATE, found: FUNCTION".to_string()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue