From 7c2a1b8feea57a46ccc0e0c6218fed9a4514be15 Mon Sep 17 00:00:00 2001 From: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com> Date: Tue, 1 Jul 2025 21:38:24 +0400 Subject: [PATCH] feat(cubesql): Support `DATE_PART` with intervals Signed-off-by: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com> --- packages/cubejs-backend-native/Cargo.lock | 12 ++++++------ rust/cubenativeutils/Cargo.lock | 12 ++++++------ rust/cubesql/Cargo.lock | 12 ++++++------ rust/cubesql/cubesql/Cargo.toml | 2 +- ...__test_df_execution__date_part_interval.snap | 9 +++++++++ .../src/compile/test/test_df_execution.rs | 17 +++++++++++++++++ rust/cubesqlplanner/Cargo.lock | 12 ++++++------ 7 files changed, 51 insertions(+), 25 deletions(-) create mode 100644 rust/cubesql/cubesql/src/compile/test/snapshots/cubesql__compile__test__test_df_execution__date_part_interval.snap diff --git a/packages/cubejs-backend-native/Cargo.lock b/packages/cubejs-backend-native/Cargo.lock index 3e5153a1234a4..084df3f674f57 100644 --- a/packages/cubejs-backend-native/Cargo.lock +++ b/packages/cubejs-backend-native/Cargo.lock @@ -714,7 +714,7 @@ dependencies = [ [[package]] name = "cube-ext" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "chrono", @@ -884,7 +884,7 @@ checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "datafusion" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -917,7 +917,7 @@ dependencies = [ [[package]] name = "datafusion-common" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "ordered-float 2.10.1", @@ -928,7 +928,7 @@ dependencies = [ [[package]] name = "datafusion-data-access" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "async-trait", "chrono", @@ -941,7 +941,7 @@ dependencies = [ [[package]] name = "datafusion-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -952,7 +952,7 @@ dependencies = [ [[package]] name = "datafusion-physical-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", diff --git a/rust/cubenativeutils/Cargo.lock b/rust/cubenativeutils/Cargo.lock index 4e8472c7df783..da0ec4fc67bf1 100644 --- a/rust/cubenativeutils/Cargo.lock +++ b/rust/cubenativeutils/Cargo.lock @@ -623,7 +623,7 @@ dependencies = [ [[package]] name = "cube-ext" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "chrono", @@ -715,7 +715,7 @@ dependencies = [ [[package]] name = "datafusion" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -748,7 +748,7 @@ dependencies = [ [[package]] name = "datafusion-common" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "ordered-float 2.10.1", @@ -759,7 +759,7 @@ dependencies = [ [[package]] name = "datafusion-data-access" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "async-trait", "chrono", @@ -772,7 +772,7 @@ dependencies = [ [[package]] name = "datafusion-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -783,7 +783,7 @@ dependencies = [ [[package]] name = "datafusion-physical-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", diff --git a/rust/cubesql/Cargo.lock b/rust/cubesql/Cargo.lock index 6877781e5896c..0b0920439a124 100644 --- a/rust/cubesql/Cargo.lock +++ b/rust/cubesql/Cargo.lock @@ -722,7 +722,7 @@ dependencies = [ [[package]] name = "cube-ext" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "chrono", @@ -846,7 +846,7 @@ dependencies = [ [[package]] name = "datafusion" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -879,7 +879,7 @@ dependencies = [ [[package]] name = "datafusion-common" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "ordered-float 2.10.0", @@ -890,7 +890,7 @@ dependencies = [ [[package]] name = "datafusion-data-access" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "async-trait", "chrono", @@ -903,7 +903,7 @@ dependencies = [ [[package]] name = "datafusion-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -914,7 +914,7 @@ dependencies = [ [[package]] name = "datafusion-physical-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", diff --git a/rust/cubesql/cubesql/Cargo.toml b/rust/cubesql/cubesql/Cargo.toml index 1a854df8f49d1..0aa50717a18f8 100644 --- a/rust/cubesql/cubesql/Cargo.toml +++ b/rust/cubesql/cubesql/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://cube.dev" [dependencies] arc-swap = "1" -datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5", default-features = false, features = [ +datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c", default-features = false, features = [ "regex_expressions", "unicode_expressions", ] } diff --git a/rust/cubesql/cubesql/src/compile/test/snapshots/cubesql__compile__test__test_df_execution__date_part_interval.snap b/rust/cubesql/cubesql/src/compile/test/snapshots/cubesql__compile__test__test_df_execution__date_part_interval.snap new file mode 100644 index 0000000000000..95306e154a33e --- /dev/null +++ b/rust/cubesql/cubesql/src/compile/test/snapshots/cubesql__compile__test__test_df_execution__date_part_interval.snap @@ -0,0 +1,9 @@ +--- +source: cubesql/src/compile/test/test_df_execution.rs +expression: "execute_query(query.to_string(), DatabaseProtocol::PostgreSQL).await.unwrap()" +--- ++---+ +| d | ++---+ +| 3 | ++---+ diff --git a/rust/cubesql/cubesql/src/compile/test/test_df_execution.rs b/rust/cubesql/cubesql/src/compile/test/test_df_execution.rs index 6c812b63743c6..aa3a04abb00ae 100644 --- a/rust/cubesql/cubesql/src/compile/test/test_df_execution.rs +++ b/rust/cubesql/cubesql/src/compile/test/test_df_execution.rs @@ -112,3 +112,20 @@ SELECT .unwrap() ); } + +#[tokio::test] +async fn test_date_part_interval() { + init_testing_logger(); + + // language=PostgreSQL + let query = r#" + SELECT + DATE_PART('day', INTERVAL '1 year 2 month 3 day 4 hour 5 minute 6 second') AS d + "#; + + insta::assert_snapshot!( + execute_query(query.to_string(), DatabaseProtocol::PostgreSQL) + .await + .unwrap() + ); +} diff --git a/rust/cubesqlplanner/Cargo.lock b/rust/cubesqlplanner/Cargo.lock index 918ab8c207749..b3d62dbda3b4d 100644 --- a/rust/cubesqlplanner/Cargo.lock +++ b/rust/cubesqlplanner/Cargo.lock @@ -664,7 +664,7 @@ dependencies = [ [[package]] name = "cube-ext" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "chrono", @@ -777,7 +777,7 @@ dependencies = [ [[package]] name = "datafusion" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -810,7 +810,7 @@ dependencies = [ [[package]] name = "datafusion-common" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "arrow", "ordered-float 2.10.1", @@ -821,7 +821,7 @@ dependencies = [ [[package]] name = "datafusion-data-access" version = "1.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "async-trait", "chrono", @@ -834,7 +834,7 @@ dependencies = [ [[package]] name = "datafusion-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow", @@ -845,7 +845,7 @@ dependencies = [ [[package]] name = "datafusion-physical-expr" version = "7.0.0" -source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5#454020d6ad0eb5987aa0dbc3a3b4db8c24ccc1b5" +source = "git+https://github.com/cube-js/arrow-datafusion.git?rev=96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c#96c5f1747e47d2d3a9b32f10484a4d8ff75cf45c" dependencies = [ "ahash 0.7.8", "arrow",