Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rust/cubesql/cubesql/src/compile/engine/udf/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,14 @@ pub fn create_measure_udaf() -> AggregateUDF {
}
});

let accumulator: AccumulatorFunctionImplementation = Arc::new(|_| todo!("Not implemented"));
let accumulator: AccumulatorFunctionImplementation = Arc::new(|_| {
Err(DataFusionError::Execution(
"This query is required to be pushed down due to use of MEASURE() function \
but planner wasn't able to. Please check that you're using MEASURE() function \
on a measure column, and that no filters prevent the pushdown"
.to_string(),
))
});

let state_type = Arc::new(vec![DataType::Float64]);
let state_type: StateTypeFunction = Arc::new(move |_, _| Ok(state_type.clone()));
Expand Down
16 changes: 16 additions & 0 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18574,4 +18574,20 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),

Ok(())
}

#[tokio::test]
async fn test_measure_func_returns_error() -> Result<(), CubeError> {
let query_result = execute_query(
// Easiest way to test `MEASURE` execution is to call it
// on a system table
"SELECT MEASURE(relname) FROM pg_class".to_string(),
DatabaseProtocol::PostgreSQL,
)
.await;

let error = query_result.expect_err("Query should return an error");
assert!(error.to_string().contains("required to be pushed down"));

Ok(())
}
}
Loading