public static Statement createStatement(TSLastDataQueryReq lastDataQueryReq)
      throws IllegalPathException {
    final long startTime = System.nanoTime();
    // construct query statement
    SelectComponent selectComponent = new SelectComponent();
    FromComponent fromComponent = new FromComponent();

    selectComponent.setHasLast(true);

    // iterate the path list and add it to from operator
    for (String pathStr : lastDataQueryReq.getPaths()) {
      PartialPath path;
      if (lastDataQueryReq.isLegalPathNodes()) {
        path = new PartialPath(pathStr.split("\\."));
      } else {
        path = new PartialPath(pathStr);
      }
      fromComponent.addPrefixPath(path);
    }
    selectComponent.addResultColumn(
        new ResultColumn(
            new TimeSeriesOperand(new PartialPath("", false)), ResultColumn.ColumnType.RAW));

    QueryStatement lastQueryStatement = new QueryStatement();

    if (lastDataQueryReq.getTime() != Long.MIN_VALUE) {
      // set query filter
      WhereCondition whereCondition = new WhereCondition();
      GreaterEqualExpression predicate =
          new GreaterEqualExpression(
              new TimestampOperand(),
              new ConstantOperand(TSDataType.INT64, Long.toString(lastDataQueryReq.getTime())));
      whereCondition.setPredicate(predicate);
      lastQueryStatement.setWhereCondition(whereCondition);
    }

    lastQueryStatement.setSelectComponent(selectComponent);
    lastQueryStatement.setFromComponent(fromComponent);
    PERFORMANCE_OVERVIEW_METRICS.recordParseCost(System.nanoTime() - startTime);

    return lastQueryStatement;
  }
Convert SQL and RPC requests to {@link Statement}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/StatementGenerator.java