@Override
    public PlanNode visitSort(SortNode node, Context context) {
      Context newContext = new Context();
      PlanNode child = node.getChild().accept(this, newContext);
      context.setHasSeenFill(newContext.hasSeenFill);
      OrderingScheme orderingScheme = node.getOrderingScheme();
      if (!context.hasSeenFill()
          && newContext.getTotalDeviceEntrySize() == 1
          && orderingScheme.getOrderBy().get(0).getName().equals(context.getTimeColumnName())) {
        return child;
      }
      return !context.hasSeenFill() && node.isOrderByAllIdsAndTime()
          ? child
          : node.replaceChildren(Collections.singletonList(child));
    }
<b>Optimization phase:</b> Distributed plan planning.

<p>This optimize rule implement the rules below.
<li>When order by time and there is only one device entry in DeviceTableScanNode below, the
    SortNode can be eliminated.
<li>When order by all IDColumns and time, the SortNode can be eliminated.
<li>When StreamSortIndex==OrderBy size()-1, remove this StreamSortNode
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/SortElimination.java