feat: implement select * ilike for snowflake (#1228)

This commit is contained in:
Hiranmaya Gundu 2024-04-21 05:22:08 -07:00 committed by GitHub
parent d1f67bdc47
commit 4604628c43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 100 additions and 3 deletions

View file

@ -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"
);
}