Skip to content

Commit 7090a0d

Browse files
committed
feat(cubesql): Move dimensions-only projections to dimensions for push-to-Cube wrapper
1 parent 71646b3 commit 7090a0d

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

rust/cubesql/cubesql/src/compile/engine/df/wrapper.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,15 @@ impl CubeScanWrapperNode {
13091309

13101310
let load_request = &ungrouped_scan_node.request;
13111311

1312+
let (dimensions_only_projection, projection_with_measures) =
1313+
projection.iter().partition::<Vec<_>, _>(
1314+
|(_column, used_members)| {
1315+
used_members.iter().all(|member| {
1316+
plan.meta.find_dimension_with_name(member).is_some()
1317+
})
1318+
},
1319+
);
1320+
13121321
let load_request = V1LoadRequestQuery {
13131322
measures: Some(
13141323
aggregate
@@ -1320,16 +1329,15 @@ impl CubeScanWrapperNode {
13201329
&ungrouped_scan_node.used_cubes,
13211330
)
13221331
})
1323-
.chain(
1324-
// TODO understand type of projections
1325-
projection.iter().map(|(m, used_members)| {
1332+
.chain(projection_with_measures.iter().map(
1333+
|(m, used_members)| {
13261334
Self::ungrouped_member_def(
13271335
m,
13281336
used_members,
13291337
&ungrouped_scan_node.used_cubes,
13301338
)
1331-
}),
1332-
)
1339+
},
1340+
))
13331341
.chain(window.iter().map(|(m, used_members)| {
13341342
Self::ungrouped_member_def(
13351343
m,
@@ -1351,6 +1359,15 @@ impl CubeScanWrapperNode {
13511359
t,
13521360
)
13531361
})
1362+
.chain(dimensions_only_projection.iter().map(
1363+
|(m, used_members)| {
1364+
Self::ungrouped_member_def(
1365+
m,
1366+
used_members,
1367+
&ungrouped_scan_node.used_cubes,
1368+
)
1369+
},
1370+
))
13541371
.collect::<Result<_>>()?,
13551372
),
13561373
segments: Some(

rust/cubesql/cubesql/src/compile/test/test_wrapper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,8 +1556,8 @@ async fn wrapper_cast_limit_explicit_members() {
15561556
.as_logical_plan()
15571557
.find_cube_scan_wrapped_sql()
15581558
.request;
1559-
assert_eq!(request.measures.unwrap().len(), 1);
1560-
assert_eq!(request.dimensions.unwrap().len(), 0);
1559+
assert_eq!(request.measures.unwrap().len(), 0);
1560+
assert_eq!(request.dimensions.unwrap().len(), 1);
15611561
}
15621562

15631563
#[tokio::test]

0 commit comments

Comments
 (0)