Expression expression = ((SelectExpressionItem) item).getExpression(); if (expression instanceof Function) { String name = ((Function) expression).getName(); if (name != null) { String NAME = name.toUpperCase();
buffer.append(function.getName()); if (function.isAllColumns() && function.getParameters() == null) { buffer.append("(*)");
public void visit(Function function) { if (function.isEscaped()) { buffer.append("{fn "); } buffer.append(function.getName()); if (function.isAllColumns()) { buffer.append("(*)"); } else if (function.getParameters() == null) { buffer.append("()"); } else { boolean oldUseBracketsInExprList = useBracketsInExprList; if (function.isDistinct()) { useBracketsInExprList = false; buffer.append("(DISTINCT "); } visit(function.getParameters()); useBracketsInExprList = oldUseBracketsInExprList; if (function.isDistinct()) { buffer.append(")"); } } if (function.isEscaped()) { buffer.append("}"); } }
public void visit(Function function) { Function qfunction = new Function(); qfunction.setAllColumns(function.isAllColumns()); qfunction.setEscaped(function.isEscaped()); qfunction.setName(function.getName()); ExpressionList parameters = function.getParameters(); ExpressionList qualifiedParams; qualifiedParams = (ExpressionList) ItemsListQualifier.qualify(session, tableAliases, parameters); qfunction.setParameters(qualifiedParams); this._qualifiedExpression = qfunction; }
public static boolean isSpecialtyFunction(Expression incomingExpression) { if (incomingExpression == null) { return false; } if (Function.class.isInstance(incomingExpression) && containsIgnoreCase(SPECIALTY_FUNCTIONS, ((Function)incomingExpression).getName())) { return true; } return false; }
private boolean isAggregateFunction(Expression expression) throws StatementExecutionException { if (!(expression instanceof Function)) { return false; } Function function = (Function) expression; String name = function.getName().toLowerCase(); if (BuiltinFunctions.isAggregateFunction(function.getName())) { return true; } if (BuiltinFunctions.isScalarFunction(function.getName())) { return false; } throw new StatementExecutionException("unsupported function " + name); }
/** * Find the FunctionDesc for a given Function. * * @param tapSchema * @param function * @return FunctionDesc */ public static FunctionDesc findFunctionDesc(TapSchema tapSchema, Function function) { if (function == null || function.getName() == null) return null; for (FunctionDesc functionDesc : tapSchema.getFunctionDescs()) { log.debug("check: " + function.getName() + " vs " + functionDesc.getName()); if (function.getName().equalsIgnoreCase(functionDesc.getName())) return functionDesc; } return null; }
@Override public void visit(net.sf.jsqlparser.expression.Function expression) { // do not use ImmutableCollectors.toList because this cannot be done concurrently ImmutableList<Term> terms = (expression.getParameters() != null) ? ImmutableList.<Term>builder() .addAll(expression.getParameters().getExpressions().stream() .map(t -> termVisitor.getTerm(t)).iterator()) .build() : ImmutableList.of(); BiFunction<ImmutableList<Term>, net.sf.jsqlparser.expression.Function, Function> function = BOOLEAN_FUNCTIONS.get(expression.getName().toUpperCase()); if (function == null) throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); result = ImmutableList.of(function.apply(terms, expression)); }
@Override public void visit(net.sf.jsqlparser.expression.Function expression) { // do not use ImmutableCollectors.toList because this cannot be done concurrently ImmutableList<Term> terms = (expression.getParameters() != null) ? ImmutableList.<Term>builder() .addAll(expression.getParameters().getExpressions().stream() .map(t -> termVisitor.getTerm(t)).iterator()) .build() : ImmutableList.of(); BiFunction<ImmutableList<Term>, net.sf.jsqlparser.expression.Function, Function> function = BOOLEAN_FUNCTIONS.get(expression.getName().toUpperCase()); if (function == null) throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); result = ImmutableList.of(function.apply(terms, expression)); }
@Override public void visit(net.sf.jsqlparser.expression.Function expression) { // do not use ImmutableCollectors.toList because this cannot be done concurrently ImmutableList<Term> terms = (expression.getParameters() != null) ? ImmutableList.<Term>builder() .addAll(expression.getParameters().getExpressions().stream() .map(t -> getTerm(t)).iterator()) .build() : ImmutableList.of(); BiFunction<ImmutableList<Term>, net.sf.jsqlparser.expression.Function, Function> function = FUNCTIONS.get(expression.getName().toUpperCase()); if (function == null) throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); result = function.apply(terms, expression); }
@Override public void visit(net.sf.jsqlparser.expression.Function expression) { // do not use ImmutableCollectors.toList because this cannot be done concurrently ImmutableList<Term> terms = (expression.getParameters() != null) ? ImmutableList.<Term>builder() .addAll(expression.getParameters().getExpressions().stream() .map(t -> getTerm(t)).iterator()) .build() : ImmutableList.of(); BiFunction<ImmutableList<Term>, net.sf.jsqlparser.expression.Function, Function> function = FUNCTIONS.get(expression.getName().toUpperCase()); if (function == null) throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); result = function.apply(terms, expression); }
@Override public void visit(Function function) { // ROMAN (22 Sep 2015): longer list of supported functions? if (function.getName().toLowerCase().equals("regexp_like")) { for (Expression ex :function.getParameters().getExpressions()) ex.accept(this); } else unsupported(function); }
@Override public Expression convertToImplementation(Function func) { Expression implExpr = super.convertToImplementation(func); if (implExpr == func) // not handled { if (RANGE_S2D.equalsIgnoreCase(func.getName())) { ExpressionList exprList = func.getParameters(); if (exprList == null) throw new IllegalArgumentException("RANGE_S2D requires long1, long2, lat1, lat2"); List<Expression> expressions = exprList.getExpressions(); if (expressions.size() != 4) throw new IllegalArgumentException("RANGE_S2D requires long1, long2, lat1, lat2"); implExpr = handleRangeS2D(expressions.get(0), expressions.get(1), expressions.get(2), expressions.get(3)); } } return implExpr; }
@Override protected Expression convertToImplementation(Function func) { if (!func.getName().equalsIgnoreCase("match")) return func; List<Expression> exprs = func.getParameters().getExpressions(); if (exprs.size() == 2) { Expression e1 = exprs.get(0); Expression e2 = exprs.get(1); if (e1 instanceof Column && e2 instanceof StringValue) { Column col = (Column) e1; String query = ((StringValue) e2).getValue(); return new TextSearchMatch(col, query); } } throw new IllegalArgumentException("invalid args to match: expected match(<column>,<string>)"); }
@Override public void visit(Function function) { switch (function.getName().toLowerCase()) { case "regexp_like" : case "regexp_replace" : case "replace" : case "concat" : case "substr" : for (Expression ex :function.getParameters().getExpressions()) ex.accept(this); break; default: unsupported(function); break; } }
@Override public void visit(Function function) { function.setName(function.getName().toLowerCase()); if (function.getParameters() != null) { function.getParameters().accept(this); } }
public static Column toAggregatedOutputColumn(String fieldName, Function f) { if (f.getName().equalsIgnoreCase(BuiltinFunctions.COUNT)) { return Column.column(fieldName, ColumnTypes.LONG); } if (f.getName().equalsIgnoreCase(BuiltinFunctions.SUM) && f.getParameters() != null && f.getParameters().getExpressions() != null && f.getParameters().getExpressions().size() == 1) { return Column.column(fieldName, ColumnTypes.LONG); } if (f.getName().equalsIgnoreCase(BuiltinFunctions.MIN) && f.getParameters() != null && f.getParameters().getExpressions() != null && f.getParameters().getExpressions().size() == 1) { return Column.column(fieldName, ColumnTypes.LONG); } if (f.getName().equalsIgnoreCase(BuiltinFunctions.MAX) && f.getParameters() != null && f.getParameters().getExpressions() != null && f.getParameters().getExpressions().size() == 1) { return Column.column(fieldName, ColumnTypes.LONG); } return null; }
@Override public void visit(Function function) { switch (function.getName().toLowerCase()) { case "regexp_like" : case "regexp_replace" : case "replace" : case "concat" : //case "substr" : for (Expression ex :function.getParameters().getExpressions()) ex.accept(this); break; default: unsupported(function); } }
public static AggregatedColumnCalculator getColumnCalculator(Function f, String fieldName, StatementEvaluationContext context) throws StatementExecutionException { String functionName = f.getName(); CompiledSQLExpression firstParam = f.getParameters() == null || f.getParameters().getExpressions() == null || f.getParameters().getExpressions().isEmpty() ? null : SQLExpressionCompiler.compileExpression(null, f.getParameters().getExpressions().get(0)); return getColumnCalculator(functionName, fieldName, firstParam, context); }
public void visit(Function function) { Function qfunction = new Function(); qfunction.setAllColumns(function.isAllColumns()); qfunction.setEscaped(function.isEscaped()); qfunction.setName(function.getName()); ExpressionList parameters = function.getParameters(); ExpressionList qualifiedParams; qualifiedParams = (ExpressionList) ItemsListQualifier.qualify(session, tableAliases, parameters); qfunction.setParameters(qualifiedParams); this._qualifiedExpression = qfunction; }