mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 14:28:22 +00:00
feat: implement select * ilike for snowflake (#1228)
This commit is contained in:
parent
d1f67bdc47
commit
4604628c43
6 changed files with 100 additions and 3 deletions
|
@ -1555,3 +1555,42 @@ fn parse_comma_outer_join() {
|
|||
fn test_sf_trailing_commas() {
|
||||
snowflake().verified_only_select_with_canonical("SELECT 1, 2, FROM t", "SELECT 1, 2 FROM t");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_select_wildcard_with_ilike() {
|
||||
let select = snowflake_and_generic().verified_only_select(r#"SELECT * ILIKE '%id%' FROM tbl"#);
|
||||
let expected = SelectItem::Wildcard(WildcardAdditionalOptions {
|
||||
opt_ilike: Some(IlikeSelectItem {
|
||||
pattern: "%id%".to_owned(),
|
||||
}),
|
||||
..Default::default()
|
||||
});
|
||||
assert_eq!(expected, select.projection[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_select_wildcard_with_ilike_double_quote() {
|
||||
let res = snowflake().parse_sql_statements(r#"SELECT * ILIKE "%id" FROM tbl"#);
|
||||
assert_eq!(
|
||||
res.unwrap_err().to_string(),
|
||||
"sql parser error: Expected ilike pattern, found: \"%id\""
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_select_wildcard_with_ilike_number() {
|
||||
let res = snowflake().parse_sql_statements(r#"SELECT * ILIKE 42 FROM tbl"#);
|
||||
assert_eq!(
|
||||
res.unwrap_err().to_string(),
|
||||
"sql parser error: Expected ilike pattern, found: 42"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_select_wildcard_with_ilike_replace() {
|
||||
let res = snowflake().parse_sql_statements(r#"SELECT * ILIKE '%id%' EXCLUDE col FROM tbl"#);
|
||||
assert_eq!(
|
||||
res.unwrap_err().to_string(),
|
||||
"sql parser error: Expected end of statement, found: EXCLUDE"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue