Skip to content

Commit 5a5d7e4

Browse files
authored
fix(cubesql): Support quicksight AVG Rebase window exprs: Physical plan does not support logical expression SUM(x) PARTITION BY (#6328)
1 parent 3ed727a commit 5a5d7e4

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

packages/cubejs-backend-native/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ index.node
66
**/node_modules
77
**/.DS_Store
88
npm-debug.log*
9+
.cargo

packages/cubejs-backend-native/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/cubesql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ documentation = "https://cube.dev/docs"
99
homepage = "https://cube.dev"
1010

1111
[dependencies]
12-
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "a29e681ada5918c6d09bb7a02aa2333ed241e7d3", default-features = false, features = ["unicode_expressions"] }
12+
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "6b006e5473160c676dcbb2d853d28b49f0e5d1ba", default-features = false, features = ["unicode_expressions"] }
1313
anyhow = "1.0"
1414
thiserror = "1.0"
1515
cubeclient = { path = "../cubeclient" }

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use datafusion::{
1414
optimizer::{OptimizerConfig, OptimizerRule},
1515
projection_drop_out::ProjectionDropOut,
1616
},
17+
physical_plan::ExecutionPlan,
1718
prelude::*,
1819
scalar::ScalarValue,
1920
sql::{parser::Statement as DFStatement, planner::SqlToRel},
@@ -1478,9 +1479,21 @@ impl fmt::Debug for QueryPlan {
14781479
}
14791480

14801481
impl QueryPlan {
1481-
pub fn as_logical_plan(self) -> LogicalPlan {
1482+
pub fn as_logical_plan(&self) -> LogicalPlan {
14821483
match self {
1483-
QueryPlan::DataFusionSelect(_, plan, _) => plan,
1484+
QueryPlan::DataFusionSelect(_, plan, _) => plan.clone(),
1485+
QueryPlan::MetaOk(_, _) | QueryPlan::MetaTabular(_, _) => {
1486+
panic!("This query doesnt have a plan, because it already has values for response")
1487+
}
1488+
}
1489+
}
1490+
1491+
pub async fn as_physical_plan(&self) -> Result<Arc<dyn ExecutionPlan>, CubeError> {
1492+
match self {
1493+
QueryPlan::DataFusionSelect(_, plan, ctx) => DataFrame::new(ctx.state.clone(), plan)
1494+
.create_physical_plan()
1495+
.await
1496+
.map_err(|e| CubeError::user(e.to_string())),
14841497
QueryPlan::MetaOk(_, _) | QueryPlan::MetaTabular(_, _) => {
14851498
panic!("This query doesnt have a plan, because it already has values for response")
14861499
}
@@ -10436,6 +10449,9 @@ ORDER BY \"COUNT(count)\" DESC"
1043610449
}
1043710450
);
1043810451

10452+
let physical_plan = query_plan.as_physical_plan().await.unwrap();
10453+
println!("Physical plan: {:?}", physical_plan);
10454+
1043910455
Ok(())
1044010456
}
1044110457

0 commit comments

Comments
 (0)