public void serialize(DataOutputStream stream) throws IOException {
    id.serialize(stream);
    if (typeProvider == null) {
      ReadWriteIOUtils.write((byte) 0, stream);
    } else {
      ReadWriteIOUtils.write((byte) 1, stream);

      // templated align by device query, the serialized attributes are same,
      // so there is no need to serialize all the SeriesScanNode repeated
      if (typeProvider.getTemplatedInfo() != null) {
        typeProvider.serialize(stream);
        planNodeTree.serializeUseTemplate(stream, typeProvider);
        return;
      }

      typeProvider.serialize(stream);
    }
    planNodeTree.serialize(stream);
  }
PlanFragment contains a sub-query of distributed query.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/PlanFragment.java