public static LogicalExpression createBooleanOperator(String functionName, List<LogicalExpression> args){ return createBooleanOperator(functionName, ExpressionPosition.UNKNOWN, args); }
public static LogicalExpression createAnyValue(String functionName, List<LogicalExpression> args) { return createExpression(functionName, args); }
public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, List<LogicalExpression> args){ String name = replaceOpWithFuncName(functionName); if (isBooleanOperator(name)) { return new BooleanOperator(name, args, ep); } else { return new FunctionCall(name, args, ep); } }
private LogicalExpression doFunction(RexCall call, String funcName) { List<LogicalExpression> args = Lists.newArrayList(); for(RexNode r : call.getOperands()){ args.add(r.accept(this)); } if (FunctionCallFactory.isBooleanOperator(funcName)) { LogicalExpression func = FunctionCallFactory.createBooleanOperator(funcName, args); return func; } else { args = Lists.reverse(args); LogicalExpression lastArg = args.get(0); for(int i = 1; i < args.size(); i++){ lastArg = FunctionCallFactory.createExpression(funcName, Lists.newArrayList(args.get(i), lastArg)); } return lastArg; } } private LogicalExpression doUnknown(RexNode o){
String functionPostfix = StringUtils.capitalize(timeUnitStr.toLowerCase()); functionName += functionPostfix; return FunctionCallFactory.createExpression(functionName, args.subList(1, 2)); default: throw new UnsupportedOperationException("extract function supports the following time units: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND"); String functionPostfix = StringUtils.capitalize(timeUnitStr.toLowerCase()); functionName += functionPostfix; return FunctionCallFactory.createExpression(functionName, args.subList(1, 3)); default: throw new UnsupportedOperationException("TIMESTAMPDIFF function supports the following time units: " + return FunctionCallFactory.createExpression(trimFunc, trimArgs); return FunctionCallFactory.createExpression("extract" + functionPostfix, args.subList(1, 2)); return FunctionCallFactory.createExpression(functionName, concatArgs); LogicalExpression first = FunctionCallFactory.createExpression(functionName, concatArgs); concatArgs.add(first); concatArgs.add(args.get(i)); first = FunctionCallFactory.createExpression(functionName, concatArgs); return FunctionCallFactory.createExpression(functionName, args.subList(0, 1)); case "convert_to": { if (args.get(1) instanceof QuotedString) { return FunctionCallFactory.createConvert(functionName, ((QuotedString) args.get(1)).value, args.get(0), ExpressionPosition.UNKNOWN);
public static boolean isBooleanOperator(String funcName) { String opName = replaceOpWithFuncName(funcName); return opName.equals("booleanAnd") || opName.equals("booleanOr"); }
setState(89); match(CParen); ((ConvertCallContext)_localctx).e = FunctionCallFactory.createConvert((((ConvertCallContext)_localctx).Convert!=null?((ConvertCallContext)_localctx).Convert.getText():null), (((ConvertCallContext)_localctx).String!=null?((ConvertCallContext)_localctx).String.getText():null), ((ConvertCallContext)_localctx).expression.e, pos(((ConvertCallContext)_localctx).Convert));
match(CParen); if (((CastCallContext)_localctx).repeat != null && ((CastCallContext)_localctx).repeat.isRep.compareTo(Boolean.TRUE)==0) ((CastCallContext)_localctx).e = FunctionCallFactory.createCast(TypeProtos.MajorType.newBuilder().mergeFrom(((CastCallContext)_localctx).dataType.type).setMode(DataMode.REPEATED).build(), pos(((CastCallContext)_localctx).Cast), ((CastCallContext)_localctx).expression.e); else ((CastCallContext)_localctx).e = FunctionCallFactory.createCast(((CastCallContext)_localctx).dataType.type, pos(((CastCallContext)_localctx).Cast), ((CastCallContext)_localctx).expression.e);
((XorExprContext)_localctx).e = FunctionCallFactory.createByOp(exprs, p, ops);
public static LogicalExpression createBooleanOperator(String functionName, ExpressionPosition ep, List<LogicalExpression> args){ return new BooleanOperator(replaceOpWithFuncName(functionName), args, ep); }
private List<NamedExpression> getExpressionList() { if (popConfig.getExprs() != null) { return popConfig.getExprs(); } final List<NamedExpression> exprs = Lists.newArrayList(); for (final MaterializedField field : incoming.getSchema()) { String fieldName = field.getName(); if (Types.isComplex(field.getType()) || Types.isRepeated(field.getType())) { final LogicalExpression convertToJson = FunctionCallFactory.createConvert(ConvertExpression.CONVERT_TO, "JSON", SchemaPath.getSimplePath(fieldName), ExpressionPosition.UNKNOWN); final String castFuncName = FunctionReplacementUtils.getCastFunc(MinorType.VARCHAR); final List<LogicalExpression> castArgs = Lists.newArrayList(); castArgs.add(convertToJson); //input_expr // implicitly casting to varchar, since we don't know actual source length, cast to undefined length, which will preserve source length castArgs.add(new ValueExpressions.LongExpression(Types.MAX_VARCHAR_LENGTH, null)); final FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN); exprs.add(new NamedExpression(castCall, new FieldReference(fieldName))); } else { exprs.add(new NamedExpression(SchemaPath.getSimplePath(fieldName), new FieldReference(fieldName))); } } return exprs; }
match(CParen); if (((CastCallContext)_localctx).repeat != null && ((CastCallContext)_localctx).repeat.isRep.compareTo(Boolean.TRUE)==0) ((CastCallContext)_localctx).e = FunctionCallFactory.createCast(TypeProtos.MajorType.newBuilder().mergeFrom(((CastCallContext)_localctx).dataType.type).setMode(DataMode.REPEATED).build(), pos(((CastCallContext)_localctx).Cast), ((CastCallContext)_localctx).expression.e); else ((CastCallContext)_localctx).e = FunctionCallFactory.createCast(((CastCallContext)_localctx).dataType.type, pos(((CastCallContext)_localctx).Cast), ((CastCallContext)_localctx).expression.e);
((EquExprContext)_localctx).e = FunctionCallFactory.createByOp(exprs, p, cmps);
public static LogicalExpression createExpression(String functionName, List<LogicalExpression> args){ return createExpression(functionName, ExpressionPosition.UNKNOWN, args); }
public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, List<LogicalExpression> args){ String name = replaceOpWithFuncName(functionName); if (isBooleanOperator(name)) { return new BooleanOperator(name, args, ep); } else { return new FunctionCall(name, args, ep); } }
public static boolean isBooleanOperator(String funcName) { String opName = replaceOpWithFuncName(funcName); return opName.equals("booleanAnd") || opName.equals("booleanOr"); }
((AndExprContext)_localctx).e = exprs.get(0); }else{ ((AndExprContext)_localctx).e = FunctionCallFactory.createBooleanOperator("and", p, exprs);
setState(89); match(CParen); ((ConvertCallContext)_localctx).e = FunctionCallFactory.createConvert((((ConvertCallContext)_localctx).Convert!=null?((ConvertCallContext)_localctx).Convert.getText():null), (((ConvertCallContext)_localctx).String!=null?((ConvertCallContext)_localctx).String.getText():null), ((ConvertCallContext)_localctx).expression.e, pos(((ConvertCallContext)_localctx).Convert));
castType = Types.required(MinorType.valueOf(call.getType().getSqlTypeName().getName())); return FunctionCallFactory.createCast(castType, ExpressionPosition.UNKNOWN, arg);
((AddExprContext)_localctx).e = FunctionCallFactory.createByOp(exprs, p, ops);