Support underscore separators in numbers for Clickhouse. Fixes #1659 (#1677)

This commit is contained in:
Paul Grau 2025-01-28 15:26:08 +02:00 committed by GitHub
parent 8de3a62948
commit 269967a6ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 99 additions and 3 deletions

View file

@ -1649,6 +1649,21 @@ fn parse_table_sample() {
clickhouse().verified_stmt("SELECT * FROM tbl SAMPLE 1 / 10 OFFSET 1 / 2");
}
#[test]
fn parse_numbers_with_underscore() {
let canonical = if cfg!(feature = "bigdecimal") {
"SELECT 10000"
} else {
"SELECT 10_000"
};
let select = clickhouse().verified_only_select_with_canonical("SELECT 10_000", canonical);
assert_eq!(
select.projection,
vec![SelectItem::UnnamedExpr(Expr::Value(number("10_000")))]
)
}
fn clickhouse() -> TestedDialects {
TestedDialects::new(vec![Box::new(ClickHouseDialect {})])
}