Skip to content

Commit

Permalink
fix: disable percentile for distributed tables (#1406)
Browse files Browse the repository at this point in the history
## Rationale
See #1405

## Detailed Changes
Disable percentile functions

## Test Plan
CI
  • Loading branch information
jiacai2050 committed Dec 27, 2023
1 parent 9974944 commit b3fd459
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions df_engine_extensions/src/dist_sql_query/physical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use datafusion::{
coalesce_batches::CoalesceBatchesExec,
coalesce_partitions::CoalescePartitionsExec,
displayable,
expressions::{ApproxPercentileCont, ApproxPercentileContWithWeight},
filter::FilterExec,
metrics::{Count, MetricValue, MetricsSet},
projection::ProjectionExec,
Expand Down Expand Up @@ -619,8 +620,20 @@ pub enum PushDownEvent {
}

impl PushDownEvent {
// Those aggregate functions can't be pushed down.
// https://github.com/apache/incubator-horaedb/issues/1405
fn blacklist_expr(expr: &dyn Any) -> bool {
expr.is::<ApproxPercentileCont>() || expr.is::<ApproxPercentileContWithWeight>()
}

pub fn new(plan: Arc<dyn ExecutionPlan>) -> Self {
if let Some(aggr) = plan.as_any().downcast_ref::<AggregateExec>() {
for aggr_expr in aggr.aggr_expr() {
if Self::blacklist_expr(aggr_expr.as_any()) {
return Self::Unable;
}
}

if *aggr.mode() == AggregateMode::Partial {
Self::Terminated(plan)
} else {
Expand Down
12 changes: 12 additions & 0 deletions integration_tests/cases/env/cluster/ddl/partition_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ tsid,t,name,id,value,
UInt64(12677620772014847982),Timestamp(1651737067000),String("ceresdb5"),Int32(0),Double(105.0),


SELECT
time_bucket (t, "PT1M") AS ts,
approx_percentile_cont (value, 0.9) AS value
FROM
random_partition_table_t
GROUP BY
time_bucket (t, "PT1M");

ts,value,
Timestamp(1651737060000),Double(109.4),


DROP TABLE IF EXISTS `random_partition_table_t`;

affected_rows: 0
Expand Down
8 changes: 8 additions & 0 deletions integration_tests/cases/env/cluster/ddl/partition_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ SELECT * from random_partition_table_t where name = "ceresdb0";

SELECT * from random_partition_table_t where name = "ceresdb5";

SELECT
time_bucket (t, "PT1M") AS ts,
approx_percentile_cont (value, 0.9) AS value
FROM
random_partition_table_t
GROUP BY
time_bucket (t, "PT1M");

DROP TABLE IF EXISTS `random_partition_table_t`;

SHOW CREATE TABLE random_partition_table_t;
Expand Down

0 comments on commit b3fd459

Please sign in to comment.