File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
rust/cubesql/cubesql/src/compile Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -18655,4 +18655,46 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1865518655
1865618656 Ok(())
1865718657 }
18658+
18659+ #[tokio::test]
18660+ async fn test_distinct_time_dimension() {
18661+ if !Rewriter::sql_push_down_enabled() {
18662+ return;
18663+ }
18664+ init_testing_logger();
18665+
18666+ let logical_plan = convert_select_to_query_plan(
18667+ r#"
18668+ SELECT DISTINCT
18669+ DATE_TRUNC('day', order_date) AS month
18670+ FROM KibanaSampleDataEcommerce
18671+ WHERE order_date >= '2025-01-01'::date AND order_date < '2025-02-01'::date
18672+ LIMIT 5
18673+ "#
18674+ .to_string(),
18675+ DatabaseProtocol::PostgreSQL,
18676+ )
18677+ .await
18678+ .as_logical_plan();
18679+
18680+ assert_eq!(
18681+ logical_plan.find_cube_scan().request,
18682+ V1LoadRequestQuery {
18683+ measures: Some(vec![]),
18684+ dimensions: Some(vec![]),
18685+ segments: Some(vec![]),
18686+ time_dimensions: Some(vec![V1LoadRequestQueryTimeDimension {
18687+ dimension: "KibanaSampleDataEcommerce.order_date".to_string(),
18688+ granularity: Some("day".to_string()),
18689+ date_range: Some(json!(vec![
18690+ "2025-01-01T00:00:00.000Z".to_string(),
18691+ "2025-01-31T23:59:59.999Z".to_string(),
18692+ ])),
18693+ }]),
18694+ order: Some(vec![]),
18695+ limit: Some(5),
18696+ ..Default::default()
18697+ }
18698+ )
18699+ }
1865818700}
Original file line number Diff line number Diff line change @@ -1620,6 +1620,7 @@ impl MemberRules {
16201620 // as it doesn't make sense for measures
16211621 match member {
16221622 Member :: Dimension { .. } => true ,
1623+ Member :: TimeDimension { .. } => true ,
16231624 Member :: VirtualField { .. } => true ,
16241625 Member :: LiteralMember { .. } => true ,
16251626 _ => false ,
You can’t perform that action at this time.
0 commit comments