mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
DuckDB: Add support for multiple TRIM
arguments (#1916)
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
parent
f32a41a004
commit
a3398223d7
3 changed files with 31 additions and 2 deletions
|
@ -7762,7 +7762,6 @@ fn parse_trim() {
|
|||
Box::new(MySqlDialect {}),
|
||||
//Box::new(BigQueryDialect {}),
|
||||
Box::new(SQLiteDialect {}),
|
||||
Box::new(DuckDbDialect {}),
|
||||
]);
|
||||
|
||||
assert_eq!(
|
||||
|
|
|
@ -24,6 +24,7 @@ use test_utils::*;
|
|||
|
||||
use sqlparser::ast::*;
|
||||
use sqlparser::dialect::{DuckDbDialect, GenericDialect};
|
||||
use sqlparser::parser::ParserError;
|
||||
|
||||
fn duckdb() -> TestedDialects {
|
||||
TestedDialects::new(vec![Box::new(DuckDbDialect {})])
|
||||
|
@ -830,3 +831,32 @@ fn parse_use() {
|
|||
])))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_duckdb_trim() {
|
||||
let real_sql = r#"SELECT customer_id, TRIM(item_price_id, '"', "a") AS item_price_id FROM models_staging.subscriptions"#;
|
||||
assert_eq!(duckdb().verified_stmt(real_sql).to_string(), real_sql);
|
||||
|
||||
let sql_only_select = "SELECT TRIM('xyz', 'a')";
|
||||
let select = duckdb().verified_only_select(sql_only_select);
|
||||
assert_eq!(
|
||||
&Expr::Trim {
|
||||
expr: Box::new(Expr::Value(
|
||||
Value::SingleQuotedString("xyz".to_owned()).with_empty_span()
|
||||
)),
|
||||
trim_where: None,
|
||||
trim_what: None,
|
||||
trim_characters: Some(vec![Expr::Value(
|
||||
Value::SingleQuotedString("a".to_owned()).with_empty_span()
|
||||
)]),
|
||||
},
|
||||
expr_from_projection(only(&select.projection))
|
||||
);
|
||||
|
||||
// missing comma separation
|
||||
let error_sql = "SELECT TRIM('xyz' 'a')";
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected: ), found: 'a'".to_owned()),
|
||||
duckdb().parse_sql_statements(error_sql).unwrap_err()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue