Пример #1
0
  private void parseMainModelClause(ModelClause modelClause) {
    MainModelClause mainModel = new MainModelClause();

    if (identifierEquals("MAIN")) {
      lexer.nextToken();
      mainModel.setMainModelName(expr());
    }

    ModelColumnClause modelColumnClause = new ModelColumnClause();
    parseQueryPartitionClause(modelColumnClause);
    mainModel.setModelColumnClause(modelColumnClause);

    acceptIdentifier("DIMENSION");
    accept(Token.BY);
    accept(Token.LPAREN);
    for (; ; ) {
      if (lexer.token() == Token.RPAREN) {
        lexer.nextToken();
        break;
      }

      ModelColumn column = new ModelColumn();
      column.setExpr(expr());
      column.setAlias(as());
      modelColumnClause.getDimensionByColumns().add(column);

      if (lexer.token() == Token.COMMA) {
        lexer.nextToken();
        continue;
      }
    }

    acceptIdentifier("MEASURES");
    accept(Token.LPAREN);
    for (; ; ) {
      if (lexer.token() == Token.RPAREN) {
        lexer.nextToken();
        break;
      }

      ModelColumn column = new ModelColumn();
      column.setExpr(expr());
      column.setAlias(as());
      modelColumnClause.getMeasuresColumns().add(column);

      if (lexer.token() == Token.COMMA) {
        lexer.nextToken();
        continue;
      }
    }
    mainModel.setModelColumnClause(modelColumnClause);

    parseCellReferenceOptions(mainModel.getCellReferenceOptions());

    parseModelRulesClause(mainModel);

    modelClause.setMainModel(mainModel);
  }
Пример #2
0
  private void parseQueryPartitionClause(ModelColumnClause modelColumnClause) {
    if (identifierEquals("PARTITION")) {
      QueryPartitionClause queryPartitionClause = new QueryPartitionClause();

      lexer.nextToken();
      accept(Token.BY);
      if (lexer.token() == Token.LPAREN) {
        lexer.nextToken();
        createExprParser().exprList(queryPartitionClause.getExprList());
        accept(Token.RPAREN);
      } else {
        createExprParser().exprList(queryPartitionClause.getExprList());
      }
      modelColumnClause.setQueryPartitionClause(queryPartitionClause);
    }
  }