Skip to content

Commit a5a97cf

Browse files
committed
add test
1 parent e13d29e commit a5a97cf

File tree

1 file changed

+43
-2
lines changed
  • rust/cubesql/cubesql/src/compile

1 file changed

+43
-2
lines changed

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15542,6 +15542,47 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1554215542
);
1554315543
}
1554415544

15545+
#[tokio::test]
15546+
async fn test_daterange_filter_literals() -> Result<(), CubeError> {
15547+
init_testing_logger();
15548+
15549+
let query_plan = convert_select_to_query_plan(
15550+
// language=PostgreSQL
15551+
r#"SELECT
15552+
DATE_TRUNC('month', order_date) AS order_date,
15553+
COUNT(*) AS month_count
15554+
FROM "KibanaSampleDataEcommerce" ecom
15555+
WHERE ecom.order_date >= '2025-01-01' and ecom.order_date < '2025-02-01'
15556+
GROUP BY 1"#
15557+
.to_string(),
15558+
DatabaseProtocol::PostgreSQL,
15559+
)
15560+
.await;
15561+
15562+
let logical_plan = query_plan.as_logical_plan();
15563+
assert_eq!(
15564+
logical_plan.find_cube_scan().request,
15565+
V1LoadRequestQuery {
15566+
measures: Some(vec!["KibanaSampleDataEcommerce.count".to_string()]),
15567+
segments: Some(vec![]),
15568+
dimensions: Some(vec![]),
15569+
time_dimensions: Some(vec![V1LoadRequestQueryTimeDimension {
15570+
dimension: "KibanaSampleDataEcommerce.order_date".to_owned(),
15571+
granularity: Some("month".to_string()),
15572+
date_range: Some(json!(vec![
15573+
// WHY NOT "2025-01-01T00:00:00.000Z".to_string(), ?
15574+
"2025-01-01".to_string(),
15575+
"2025-01-31T23:59:59.999Z".to_string()
15576+
])),
15577+
}]),
15578+
order: Some(vec![]),
15579+
..Default::default()
15580+
}
15581+
);
15582+
15583+
Ok(())
15584+
}
15585+
1554515586
#[tokio::test]
1554615587
async fn test_time_dimension_range_filter_chain_or() {
1554715588
init_testing_logger();
@@ -15585,7 +15626,7 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1558515626
operator: Some("inDateRange".to_string()),
1558615627
values: Some(vec![
1558715628
"2019-01-01 00:00:00.0".to_string(),
15588-
"2020-01-01 00:00:00.0".to_string(),
15629+
"2019-12-31T23:59:59.999Z".to_string(),
1558915630
]),
1559015631
or: None,
1559115632
and: None,
@@ -15595,7 +15636,7 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1559515636
operator: Some("inDateRange".to_string()),
1559615637
values: Some(vec![
1559715638
"2021-01-01 00:00:00.0".to_string(),
15598-
"2022-01-01 00:00:00.0".to_string(),
15639+
"2021-12-31T23:59:59.999Z".to_string(),
1559915640
]),
1560015641
or: None,
1560115642
and: None,

0 commit comments

Comments
 (0)