@Override
  public Operator visitProject(ProjectNode node, LocalExecutionPlanContext context) {
    Operator child = node.getChild().accept(this, context);
    OperatorContext operatorContext =
        context
            .getDriverContext()
            .addOperatorContext(
                context.getNextOperatorId(),
                node.getPlanNodeId(),
                ProjectOperator.class.getSimpleName());

    List<String> inputColumnNames;
    List<String> outputColumnNames = node.getOutputColumnNames();
    if (outputColumnNames == null) {
      if (context.getTypeProvider().getTemplatedInfo().isAggregationQuery()) {
        outputColumnNames = context.getTypeProvider().getTemplatedInfo().getDeviceViewOutputNames();
        outputColumnNames = outputColumnNames.subList(1, outputColumnNames.size());
        inputColumnNames = node.getChild().getOutputColumnNames();
      } else {
        outputColumnNames = context.getTypeProvider().getTemplatedInfo().getDeviceViewOutputNames();
        // skip device column
        outputColumnNames = outputColumnNames.subList(1, outputColumnNames.size());
        inputColumnNames = context.getTypeProvider().getTemplatedInfo().getMeasurementList();
      }
    } else {
      inputColumnNames = node.getChild().getOutputColumnNames();
    }

    if (inputColumnNames.equals(outputColumnNames)) {
      // no need to project
      return child;
    }

    List<Integer> remainingColumnIndexList = new ArrayList<>();
    for (String outputColumnName : outputColumnNames) {
      int index = inputColumnNames.indexOf(outputColumnName);
      if (index < 0) {
        throw new IllegalStateException(
            String.format("Cannot find column [%s] in child's output", outputColumnName));
      }
      remainingColumnIndexList.add(index);
    }
    return new ProjectOperator(operatorContext, child, remainingColumnIndexList);
  }
This Visitor is responsible for transferring PlanNode Tree to Operator Tree.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java