private boolean needShuffleSinkNode(
      QueryStatement queryStatement, NodeGroupContext nodeGroupContext) {
    OrderByComponent orderByComponent = queryStatement.getOrderByComponent();

    if (nodeGroupContext.isAlignByDevice() && orderByComponent != null) {

      // TopKNode will use IdentityNode but not ShuffleSinkNode
      if (queryStatement.hasLimit()
          && !queryStatement.isOrderByBasedOnDevice()
          && queryStatement.getRowLimit() <= LIMIT_VALUE_USE_TOP_K) {
        return false;
      }

      return !orderByComponent.getSortItemList().isEmpty()
          && (orderByComponent.isBasedOnTime() && !queryStatement.hasOrderByExpression());
    }

    return false;
  }
Return true if we need to use ShuffleSinkNode instead of IdentitySinkNode.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/DistributionPlanner.java