Skip to content

Commit 54bdfee

Browse files
committed
feat(cubesql): Support Date32 to Timestamp coercion
1 parent 3301e71 commit 54bdfee

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

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
@@ -9,7 +9,7 @@ documentation = "https://cube.dev/docs"
99
homepage = "https://cube.dev"
1010

1111
[dependencies]
12-
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "90f0168023bce6b7fa44d3473dd052afd444ca54", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
12+
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "915a600ea4d3b66161cd77ff94747960f840816e", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
1313
anyhow = "1.0"
1414
thiserror = "1.0"
1515
cubeclient = { path = "../cubeclient" }

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12912,6 +12912,33 @@ ORDER BY \"COUNT(count)\" DESC"
1291212912
Ok(())
1291312913
}
1291412914

12915+
#[tokio::test]
12916+
async fn test_holistics_date_trunc_date32() -> Result<(), CubeError> {
12917+
insta::assert_snapshot!(
12918+
"holistics_date_trunc_date32",
12919+
execute_query(
12920+
"
12921+
with \"h__dates\" AS (
12922+
SELECT
12923+
CAST ('2023-02-01' AS date) as \"start_range\",
12924+
CAST ( '2023-02-28' AS date ) as \"end_range\",
12925+
28 as \"length\"
12926+
)
12927+
SELECT
12928+
DATE_TRUNC( 'month', \"start_range\") AS \"dm_ddt_d_6e2110\",
12929+
MAX(\"length\") AS \"h_dates_length\"
12930+
FROM \"h__dates\"
12931+
GROUP BY 1
12932+
"
12933+
.to_string(),
12934+
DatabaseProtocol::PostgreSQL
12935+
)
12936+
.await?
12937+
);
12938+
12939+
Ok(())
12940+
}
12941+
1291512942
#[tokio::test]
1291612943
async fn test_holistics_group_by_date() {
1291712944
init_logger();
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(\"\n with \\\"h__dates\\\" AS (\n SELECT\n CAST ('2023-02-01' AS date) as \\\"start_range\\\",\n CAST ( '2023-02-28' AS date ) as \\\"end_range\\\",\n 28 as \\\"length\\\"\n )\n SELECT\n DATE_TRUNC( 'month', \\\"start_range\\\") AS \\\"dm_ddt_d_6e2110\\\",\n MAX(\\\"length\\\") AS \\\"h_dates_length\\\"\n FROM \\\"h__dates\\\"\n GROUP BY 1\n \".to_string(),\n DatabaseProtocol::PostgreSQL).await?"
4+
---
5+
+-------------------------+----------------+
6+
| dm_ddt_d_6e2110 | h_dates_length |
7+
+-------------------------+----------------+
8+
| 2023-02-01T00:00:00.000 | 28 |
9+
+-------------------------+----------------+

0 commit comments

Comments
 (0)