@@ -22862,4 +22862,160 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
2286222862 }
2286322863 )
2286422864 }
22865+
22866+ #[tokio::test]
22867+ async fn test_filter_datetrunc_in_date_range_merged() {
22868+ init_logger();
22869+
22870+ let logical_plan = convert_select_to_query_plan(
22871+ r#"
22872+ select
22873+ DATE_TRUNC('year', order_date) as "c0",
22874+ sum("KibanaSampleDataEcommerce"."sumPrice") as "m0"
22875+ from
22876+ "KibanaSampleDataEcommerce" as "KibanaSampleDataEcommerce"
22877+ where
22878+ DATE_TRUNC('year', order_date) in (
22879+ '2019-01-01 00:00:00.0',
22880+ '2020-01-01 00:00:00.0',
22881+ '2021-01-01 00:00:00.0',
22882+ '2022-01-01 00:00:00.0',
22883+ '2023-01-01 00:00:00.0'
22884+ )
22885+ group by
22886+ DATE_TRUNC('year', order_date)
22887+ "#
22888+ .to_string(),
22889+ DatabaseProtocol::PostgreSQL,
22890+ )
22891+ .await
22892+ .as_logical_plan();
22893+
22894+ assert_eq!(
22895+ logical_plan.find_cube_scan().request,
22896+ V1LoadRequestQuery {
22897+ measures: Some(vec!["KibanaSampleDataEcommerce.sumPrice".to_string()]),
22898+ dimensions: Some(vec![]),
22899+ segments: Some(vec![]),
22900+ time_dimensions: Some(vec![V1LoadRequestQueryTimeDimension {
22901+ dimension: "KibanaSampleDataEcommerce.order_date".to_string(),
22902+ granularity: Some("year".to_string()),
22903+ date_range: Some(json!(vec![
22904+ "2019-01-01 00:00:00.000".to_string(),
22905+ "2023-12-31 23:59:59.999".to_string()
22906+ ])),
22907+ }]),
22908+ order: None,
22909+ limit: None,
22910+ offset: None,
22911+ filters: None,
22912+ ungrouped: None,
22913+ }
22914+ )
22915+ }
22916+
22917+ #[tokio::test]
22918+ async fn test_filter_datetrunc_in_date_range_separate() {
22919+ init_logger();
22920+
22921+ let logical_plan = convert_select_to_query_plan(
22922+ r#"
22923+ select
22924+ DATE_TRUNC('quarter', order_date) as "c0",
22925+ sum("KibanaSampleDataEcommerce"."sumPrice") as "m0"
22926+ from
22927+ "KibanaSampleDataEcommerce" as "KibanaSampleDataEcommerce"
22928+ where
22929+ DATE_TRUNC('quarter', order_date) in (
22930+ '2019-01-01 00:00:00.0',
22931+ '2020-01-01 00:00:00.0',
22932+ '2021-01-01 00:00:00.0',
22933+ '2022-01-01 00:00:00.0',
22934+ '2023-01-01 00:00:00.0'
22935+ )
22936+ group by
22937+ DATE_TRUNC('quarter', order_date)
22938+ "#
22939+ .to_string(),
22940+ DatabaseProtocol::PostgreSQL,
22941+ )
22942+ .await
22943+ .as_logical_plan();
22944+
22945+ assert_eq!(
22946+ logical_plan.find_cube_scan().request,
22947+ V1LoadRequestQuery {
22948+ measures: Some(vec!["KibanaSampleDataEcommerce.sumPrice".to_string()]),
22949+ dimensions: Some(vec![]),
22950+ segments: Some(vec![]),
22951+ time_dimensions: Some(vec![V1LoadRequestQueryTimeDimension {
22952+ dimension: "KibanaSampleDataEcommerce.order_date".to_string(),
22953+ granularity: Some("quarter".to_string()),
22954+ date_range: None
22955+ }]),
22956+ order: None,
22957+ limit: None,
22958+ offset: None,
22959+ filters: Some(vec![V1LoadRequestQueryFilterItem {
22960+ member: None,
22961+ operator: None,
22962+ values: None,
22963+ or: Some(vec![
22964+ json!(V1LoadRequestQueryFilterItem {
22965+ member: Some("KibanaSampleDataEcommerce.order_date".to_string()),
22966+ operator: Some("inDateRange".to_string()),
22967+ values: Some(vec![
22968+ "2019-01-01 00:00:00.000".to_string(),
22969+ "2019-03-31 23:59:59.999".to_string(),
22970+ ]),
22971+ or: None,
22972+ and: None,
22973+ }),
22974+ json!(V1LoadRequestQueryFilterItem {
22975+ member: Some("KibanaSampleDataEcommerce.order_date".to_string()),
22976+ operator: Some("inDateRange".to_string()),
22977+ values: Some(vec![
22978+ "2020-01-01 00:00:00.000".to_string(),
22979+ "2020-03-31 23:59:59.999".to_string(),
22980+ ]),
22981+ or: None,
22982+ and: None,
22983+ }),
22984+ json!(V1LoadRequestQueryFilterItem {
22985+ member: Some("KibanaSampleDataEcommerce.order_date".to_string()),
22986+ operator: Some("inDateRange".to_string()),
22987+ values: Some(vec![
22988+ "2021-01-01 00:00:00.000".to_string(),
22989+ "2021-03-31 23:59:59.999".to_string(),
22990+ ]),
22991+ or: None,
22992+ and: None,
22993+ }),
22994+ json!(V1LoadRequestQueryFilterItem {
22995+ member: Some("KibanaSampleDataEcommerce.order_date".to_string()),
22996+ operator: Some("inDateRange".to_string()),
22997+ values: Some(vec![
22998+ "2022-01-01 00:00:00.000".to_string(),
22999+ "2022-03-31 23:59:59.999".to_string(),
23000+ ]),
23001+ or: None,
23002+ and: None,
23003+ }),
23004+ json!(V1LoadRequestQueryFilterItem {
23005+ member: Some("KibanaSampleDataEcommerce.order_date".to_string()),
23006+ operator: Some("inDateRange".to_string()),
23007+ values: Some(vec![
23008+ "2023-01-01 00:00:00.000".to_string(),
23009+ "2023-03-31 23:59:59.999".to_string(),
23010+ ]),
23011+ or: None,
23012+ and: None,
23013+ }),
23014+ ]),
23015+ and: None
23016+ }]),
23017+ ungrouped: None,
23018+ }
23019+ )
23020+ }
2286523021}
0 commit comments