| 16 | * from the execution plan. */ |
| 17 | |
| 18 | void reduceDistinct(ExecutionPlan *plan) { |
| 19 | // Look for Distinct operations. |
| 20 | OpBase **distinct_ops = ExecutionPlan_CollectOps(plan->root, OPType_DISTINCT); |
| 21 | |
| 22 | for(uint i = 0; i < array_len(distinct_ops); i++) { |
| 23 | OpBase *distinct = distinct_ops[i]; |
| 24 | ASSERT(distinct->childCount == 1); |
| 25 | if(distinct->children[0]->type == OPType_AGGREGATE) { |
| 26 | // We can remove the Distinct op if its child is an aggregate operation, |
| 27 | // as its results will inherently be unique. |
| 28 | ExecutionPlan_RemoveOp(plan, distinct); |
| 29 | OpBase_Free(distinct); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | array_free(distinct_ops); |
| 34 | } |
| 35 |
no test coverage detected