|
35 | 35 | import org.apache.iotdb.db.queryengine.plan.expression.Expression; |
36 | 36 | import org.apache.iotdb.db.queryengine.plan.expression.leaf.TimeSeriesOperand; |
37 | 37 | import org.apache.iotdb.db.queryengine.plan.expression.multi.FunctionExpression; |
| 38 | +import org.apache.iotdb.db.queryengine.plan.expression.multi.FunctionType; |
38 | 39 | import org.apache.iotdb.db.queryengine.plan.planner.plan.node.BaseSourceRewriter; |
39 | 40 | import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode; |
40 | 41 | import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId; |
@@ -217,7 +218,7 @@ public List<PlanNode> visitDeviceView(DeviceViewNode node, DistributionPlanConte |
217 | 218 | analysis.getPartitionInfo(outputDevice, context.getPartitionTimeFilter())); |
218 | 219 | if (regionReplicaSets.size() > 1 && !existDeviceCrossRegion) { |
219 | 220 | existDeviceCrossRegion = true; |
220 | | - if (analysis.isDeviceViewSpecialProcess() && aggregationCannotUseMergeSort()) { |
| 221 | + if (analysis.isDeviceViewSpecialProcess() && cannotUseAggMergeSort()) { |
221 | 222 | return processSpecialDeviceView(node, context); |
222 | 223 | } |
223 | 224 | } |
@@ -387,18 +388,22 @@ private static List<Expression> getWithDeviceExpressions( |
387 | 388 | } |
388 | 389 |
|
389 | 390 | /** |
390 | | - * aggregation align by device, and aggregation is `count_if` or `diff`, or aggregation used with |
391 | | - * group by parameter (session, variation, count), use the old aggregation logic |
| 391 | + * 1. aggregation align by device, and aggregation is `count_if` or `diff`, or aggregation used |
| 392 | + * with 2. group by parameter (session, variation, count), use the old aggregation logic 3. |
| 393 | + * non-mappable UDTF, we just need to check UDTF in this method, because caller has already |
| 394 | + * checked analysis.isDeviceViewSpecialProcess() |
392 | 395 | */ |
393 | | - private boolean aggregationCannotUseMergeSort() { |
| 396 | + private boolean cannotUseAggMergeSort() { |
394 | 397 | if (analysis.hasGroupByParameter()) { |
395 | 398 | return true; |
396 | 399 | } |
397 | 400 |
|
398 | 401 | for (Expression expression : analysis.getDeviceViewOutputExpressions()) { |
399 | 402 | if (expression instanceof FunctionExpression) { |
400 | 403 | String functionName = ((FunctionExpression) expression).getFunctionName(); |
401 | | - if (COUNT_IF.equalsIgnoreCase(functionName) || DIFF.equalsIgnoreCase(functionName)) { |
| 404 | + if (((FunctionExpression) expression).getFunctionType() == FunctionType.UDTF |
| 405 | + || COUNT_IF.equalsIgnoreCase(functionName) |
| 406 | + || DIFF.equalsIgnoreCase(functionName)) { |
402 | 407 | return true; |
403 | 408 | } |
404 | 409 | } |
|
0 commit comments