Skip to content

Commit 5ce589a

Browse files
authored
feat(cubesql): Support Null input type in SUM and AVG functions
1 parent 1d598d0 commit 5ce589a

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

packages/cubejs-backend-native/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 = "370f91fda4a7e9387dded4edaf2425c447e76fbd", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
13+
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "8d98b8587052b35888d29d70ba94618bd913ad39", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
1414
anyhow = "1.0"
1515
thiserror = "1.0.50"
1616
cubeclient = { path = "../cubeclient" }

rust/cubesql/cubesql/src/compile/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24300,4 +24300,29 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
2430024300
}
2430124301
)
2430224302
}
24303+
24304+
#[tokio::test]
24305+
async fn test_sum_avg_null_type() -> Result<(), CubeError> {
24306+
init_logger();
24307+
24308+
insta::assert_snapshot!(
24309+
"sum_null_type",
24310+
execute_query(
24311+
"SELECT SUM(x) FROM (SELECT NULL AS x) AS t".to_string(),
24312+
DatabaseProtocol::PostgreSQL
24313+
)
24314+
.await?
24315+
);
24316+
24317+
insta::assert_snapshot!(
24318+
"avg_null_type",
24319+
execute_query(
24320+
"SELECT AVG(x) FROM (SELECT NULL AS x) AS t".to_string(),
24321+
DatabaseProtocol::PostgreSQL
24322+
)
24323+
.await?
24324+
);
24325+
24326+
Ok(())
24327+
}
2430324328
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
source: cubesql/src/compile/mod.rs
3+
expression: "execute_query(\"SELECT AVG(x) FROM (SELECT NULL AS x) AS t\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
4+
---
5+
+----------+
6+
| AVG(t.x) |
7+
+----------+
8+
| NULL |
9+
+----------+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
source: cubesql/src/compile/mod.rs
3+
expression: "execute_query(\"SELECT SUM(x) FROM (SELECT NULL AS x) AS t\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
4+
---
5+
+----------+
6+
| SUM(t.x) |
7+
+----------+
8+
| NULL |
9+
+----------+

0 commit comments

Comments
 (0)