Example #1
0
  private void visit(FunctionMethod function) {
    if (this.filter != null && !filter.matcher(function.getName()).matches()) {
      return;
    }
    append(CREATE).append(SPACE);
    if (function.getPushdown().equals(FunctionMethod.PushDown.MUST_PUSHDOWN)) {
      append(FOREIGN);
    } else {
      append(VIRTUAL);
    }
    append(SPACE)
        .append(FUNCTION)
        .append(SPACE)
        .append(SQLStringVisitor.escapeSinglePart(function.getName()));
    append(LPAREN);

    boolean first = true;
    for (FunctionParameter fp : function.getInputParameters()) {
      if (first) {
        first = false;
      } else {
        append(COMMA).append(SPACE);
      }
      visit(fp);
    }
    append(RPAREN);

    append(SPACE).append(RETURNS);
    appendOptions(function.getOutputParameter());
    append(SPACE);
    append(function.getOutputParameter().getType());

    // options
    String options = buildFunctionOptions(function);
    if (!options.isEmpty()) {
      append(NEWLINE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
    }

    /*if (function.getDefinition() != null) {
    	append(NEWLINE).append(SQLConstants.Reserved.AS).append(NEWLINE);
    	append(function.getDefinition());
    }*/

    append(SQLConstants.Tokens.SEMICOLON);
  }