private void resolveFunctionCallAndMeasureWindows(QuerySpecification querySpecification) {
      ImmutableList.Builder<Expression> expressions = ImmutableList.builder();

      // SELECT expressions and ORDER BY expressions can contain window functions
      for (SelectItem item : querySpecification.getSelect().getSelectItems()) {
        if (item instanceof AllColumns) {
          ((AllColumns) item).getTarget().ifPresent(expressions::add);
        } else if (item instanceof SingleColumn) {
          expressions.add(((SingleColumn) item).getExpression());
        }
      }
      for (SortItem sortItem : getSortItemsFromOrderBy(querySpecification.getOrderBy())) {
        expressions.add(sortItem.getSortKey());
      }

      for (FunctionCall windowFunction : extractWindowFunctions(expressions.build())) {
        Analysis.ResolvedWindow resolvedWindow =
            resolveWindowSpecification(querySpecification, windowFunction.getWindow().get());
        analysis.setWindow(windowFunction, resolvedWindow);
      }
    }
Visitor context represents local query scope (if exists). The invariant is that the local query
scopes hierarchy should always have outer query scope (if provided) as ancestor.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java