Skip to content

Commit 8cd1dfe

Browse files
authored
feat(cubesql): Support round() function with two parameters (#9594)
1 parent fd88944 commit 8cd1dfe

File tree

10 files changed

+56
-3787
lines changed

10 files changed

+56
-3787
lines changed

packages/cubejs-backend-native/Cargo.lock

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubenativeutils/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/cubesql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage = "https://cube.dev"
1010

1111
[dependencies]
1212
arc-swap = "1"
13-
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "1a612fc26f762f3837ecf26df2e83ba38f11a8a2", default-features = false, features = [
13+
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "ce2af2c8fce31f365050471f7c6e80786d73b962", default-features = false, features = [
1414
"regex_expressions",
1515
"unicode_expressions",
1616
] }

rust/cubesql/cubesql/src/compile/rewrite/language.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ macro_rules! variant_field_struct {
364364
BuiltinScalarFunction::Log => "Log",
365365
BuiltinScalarFunction::Log10 => "Log10",
366366
BuiltinScalarFunction::Log2 => "Log2",
367+
BuiltinScalarFunction::Power => "Power",
367368
BuiltinScalarFunction::Round => "Round",
368369
BuiltinScalarFunction::Signum => "Signum",
369370
BuiltinScalarFunction::Sin => "Sin",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
source: cubesql/src/compile/test/test_df_execution.rs
3+
expression: "execute_query(query.to_string(), DatabaseProtocol::PostgreSQL).await.unwrap()"
4+
---
5+
+----------------------+----------------------------------+-----------------------------------+
6+
| round(Float64(42.4)) | round(Float64(42.4382),Int64(2)) | round(Float64(1234.56),Int64(-1)) |
7+
+----------------------+----------------------------------+-----------------------------------+
8+
| 42 | 42.44 | 1230 |
9+
+----------------------+----------------------------------+-----------------------------------+

rust/cubesql/cubesql/src/compile/test/test_df_execution.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,24 @@ GROUP BY
9191
.unwrap()
9292
);
9393
}
94+
95+
/// See https://www.postgresql.org/docs/current/functions-math.html
96+
#[tokio::test]
97+
async fn test_round() {
98+
init_testing_logger();
99+
100+
// language=PostgreSQL
101+
let query = r#"
102+
SELECT
103+
round(42.4), -- 42
104+
round(42.4382, 2), -- 42.44
105+
round(1234.56, -1) -- 1230
106+
;
107+
"#;
108+
109+
insta::assert_snapshot!(
110+
execute_query(query.to_string(), DatabaseProtocol::PostgreSQL)
111+
.await
112+
.unwrap()
113+
);
114+
}

rust/cubesqlplanner/Cargo.lock

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)