public AnalyzedStatement next()

in zetasql-toolkit-core/src/main/java/com/google/zetasql/toolkit/ZetaSQLToolkitAnalyzer.java [184:219]


    public AnalyzedStatement next() {
      int startPosition = parseResumeLocation.getBytePosition();

      ASTStatement parsedStatement = parseNextStatement(parseResumeLocation);

      this.reachedComplexScriptStatement =
          this.reachedComplexScriptStatement || isComplexScriptStatement(parsedStatement);

      // If the statement is a variable declaration, we need to validate it and create a
      // Constant
      // in the catalog
      if (parsedStatement instanceof ASTVariableDeclaration) {
        this.applyVariableDeclaration((ASTVariableDeclaration) parsedStatement);
      }

      // If the statement is an assignment (SET statement), we need to validate it
      if (parsedStatement instanceof ASTSingleAssignment) {
        this.validateSingleAssignment((ASTSingleAssignment) parsedStatement);
      }

      this.validateProcedureAndTVFReferences(parsedStatement);

      if (this.reachedComplexScriptStatement || this.isScriptStatement(parsedStatement)) {
        return new AnalyzedStatement(parsedStatement, Optional.empty());
      }

      String rewrittenQuery = StatementRewriter.quoteNamePaths(query, parsedStatement);
      ParseResumeLocation analysisParseResumeLocation = new ParseResumeLocation(rewrittenQuery);
      analysisParseResumeLocation.setBytePosition(startPosition);

      ResolvedStatement resolvedStatement = analyzeNextStatement(analysisParseResumeLocation);

      this.applyCatalogMutation(resolvedStatement);

      return new AnalyzedStatement(parsedStatement, Optional.of(resolvedStatement));
    }