mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-29 02:14:07 +00:00
Support TRIM syntax (#331)
* Support TRIM syntax - Implement the following cases - TRIM([BOTH | LEADING | TRAILING] <expr> [FROM <expr>]) - TRIM(<expr>) * Resolve 1.54.0 clippy error - Remove needless borrow * Add test cases for TRIM
This commit is contained in:
parent
67e17b27f5
commit
e548d38de8
3 changed files with 64 additions and 0 deletions
|
@ -2747,6 +2747,26 @@ fn parse_substring() {
|
|||
one_statement_parses_to("SELECT SUBSTRING('1' FOR 3)", "SELECT SUBSTRING('1' FOR 3)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_trim() {
|
||||
one_statement_parses_to(
|
||||
"SELECT TRIM(BOTH 'xyz' FROM 'xyzfooxyz')",
|
||||
"SELECT TRIM(BOTH 'xyz' FROM 'xyzfooxyz')",
|
||||
);
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT TRIM(LEADING 'xyz' FROM 'xyzfooxyz')",
|
||||
"SELECT TRIM(LEADING 'xyz' FROM 'xyzfooxyz')",
|
||||
);
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT TRIM(TRAILING 'xyz' FROM 'xyzfooxyz')",
|
||||
"SELECT TRIM(TRAILING 'xyz' FROM 'xyzfooxyz')",
|
||||
);
|
||||
|
||||
one_statement_parses_to("SELECT TRIM(' foo ')", "SELECT TRIM(' foo ')");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_exists_subquery() {
|
||||
let expected_inner = verified_query("SELECT 1");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue