Skip to content

Commit

Permalink
feat(cubesql): Support Date32 to Timestamp coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
MazterQyou committed Aug 31, 2023
1 parent 3301e71 commit 54bdfee
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
12 changes: 6 additions & 6 deletions rust/cubesql/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/cubesql/cubesql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation = "https://cube.dev/docs"
homepage = "https://cube.dev"

[dependencies]
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "90f0168023bce6b7fa44d3473dd052afd444ca54", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "915a600ea4d3b66161cd77ff94747960f840816e", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
anyhow = "1.0"
thiserror = "1.0"
cubeclient = { path = "../cubeclient" }
Expand Down
27 changes: 27 additions & 0 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12912,6 +12912,33 @@ ORDER BY \"COUNT(count)\" DESC"
Ok(())
}

#[tokio::test]
async fn test_holistics_date_trunc_date32() -> Result<(), CubeError> {
insta::assert_snapshot!(
"holistics_date_trunc_date32",
execute_query(
"
with \"h__dates\" AS (
SELECT
CAST ('2023-02-01' AS date) as \"start_range\",
CAST ( '2023-02-28' AS date ) as \"end_range\",
28 as \"length\"
)
SELECT
DATE_TRUNC( 'month', \"start_range\") AS \"dm_ddt_d_6e2110\",
MAX(\"length\") AS \"h_dates_length\"
FROM \"h__dates\"
GROUP BY 1
"
.to_string(),
DatabaseProtocol::PostgreSQL
)
.await?
);

Ok(())
}

#[tokio::test]
async fn test_holistics_group_by_date() {
init_logger();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: cubesql/src/compile/mod.rs
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?"
---
+-------------------------+----------------+
| dm_ddt_d_6e2110 | h_dates_length |
+-------------------------+----------------+
| 2023-02-01T00:00:00.000 | 28 |
+-------------------------+----------------+

0 comments on commit 54bdfee

Please sign in to comment.