public static LogicalExpression createAnyValue(String functionName, List<LogicalExpression> args) { return createExpression(functionName, args); }
public static LogicalExpression createExpression(String functionName, List<LogicalExpression> args){ return createExpression(functionName, ExpressionPosition.UNKNOWN, args); }
public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, LogicalExpression... e){ return createExpression(functionName, ep, Lists.newArrayList(e)); }
public static LogicalExpression createByOp(List<LogicalExpression> args, ExpressionPosition ep, List<String> opTypes) { if (args.size() == 1) { return args.get(0); } if (args.size() - 1 != opTypes.size()) { throw new DrillRuntimeException("Must receive one more expression then the provided number of operators."); } LogicalExpression first = args.get(0); for (int i = 0; i < opTypes.size(); i++) { List<LogicalExpression> l2 = new ArrayList<LogicalExpression>(); l2.add(first); l2.add(args.get(i + 1)); first = createExpression(opTypes.get(i), ep, l2); } return first; }
((RelExprContext)_localctx).e = FunctionCallFactory.createExpression((((RelExprContext)_localctx).cmpr!=null?((RelExprContext)_localctx).cmpr.getText():null), pos((((RelExprContext)_localctx).left!=null?(((RelExprContext)_localctx).left.start):null)), ((RelExprContext)_localctx).left.e, ((RelExprContext)_localctx).right.e);
match(CParen); ((FunctionCallContext)_localctx).e = FunctionCallFactory.createExpression((((FunctionCallContext)_localctx).Identifier!=null?((FunctionCallContext)_localctx).Identifier.getText():null), pos(((FunctionCallContext)_localctx).Identifier), (((FunctionCallContext)_localctx).exprList == null ? new ArrayList<>() : ((FunctionCallContext)_localctx).exprList.listE));
match(CParen); ((AnyValueCallContext)_localctx).e = FunctionCallFactory.createExpression((((AnyValueCallContext)_localctx).AnyValue!=null?((AnyValueCallContext)_localctx).AnyValue.getText():null), pos(((AnyValueCallContext)_localctx).AnyValue), (((AnyValueCallContext)_localctx).exprList == null ? new ArrayList<>() : ((AnyValueCallContext)_localctx).exprList.listE));
setState(389); ((UnaryExprContext)_localctx).atom = atom(); ((UnaryExprContext)_localctx).e = FunctionCallFactory.createExpression("u-", pos(((UnaryExprContext)_localctx).Minus), ((UnaryExprContext)_localctx).atom.e); setState(393); ((UnaryExprContext)_localctx).atom = atom(); ((UnaryExprContext)_localctx).e = FunctionCallFactory.createExpression("!", pos(((UnaryExprContext)_localctx).Excl), ((UnaryExprContext)_localctx).atom.e);
public static LogicalExpression createAnyValue(String functionName, List<LogicalExpression> args) { return createExpression(functionName, args); }
public static LogicalExpression createExpression(String functionName, List<LogicalExpression> args){ return createExpression(functionName, ExpressionPosition.UNKNOWN, args); }
public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, LogicalExpression... e){ return createExpression(functionName, ep, Lists.newArrayList(e)); }
public static LogicalExpression createByOp(List<LogicalExpression> args, ExpressionPosition ep, List<String> opTypes) { if (args.size() == 1) { return args.get(0); } if (args.size() - 1 != opTypes.size()) { throw new DrillRuntimeException("Must receive one more expression then the provided number of operators."); } LogicalExpression first = args.get(0); for (int i = 0; i < opTypes.size(); i++) { List<LogicalExpression> l2 = new ArrayList<LogicalExpression>(); l2.add(first); l2.add(args.get(i + 1)); first = createExpression(opTypes.get(i), ep, l2); } return first; }
private LogicalExpression handleDateTruncFunction(final List<LogicalExpression> args) { // Assert that the first argument to extract is a QuotedString assert args.get(0) instanceof ValueExpressions.QuotedString; // Get the unit of time to be extracted String timeUnitStr = ((ValueExpressions.QuotedString) args.get(0)).value.toUpperCase(); TimeUnit timeUnit = TimeUnit.valueOf(timeUnitStr); switch (timeUnit) { case YEAR: case MONTH: case DAY: case HOUR: case MINUTE: case SECOND: case WEEK: case QUARTER: case DECADE: case CENTURY: case MILLENNIUM: final String functionPostfix = StringUtils.capitalize(timeUnitStr.toLowerCase()); return FunctionCallFactory.createExpression("date_trunc_" + functionPostfix, args.subList(1, 2)); } throw new UnsupportedOperationException("date_trunc function supports the following time units: " + "YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, WEEK, QUARTER, DECADE, CENTURY, MILLENNIUM"); }
public static LogicalExpression toDrill(AggregateCall call, List<String> fn, DrillImplementor implementor) { List<LogicalExpression> args = Lists.newArrayList(); for(Integer i : call.getArgList()) { args.add(new FieldReference(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1L)); } return FunctionCallFactory.createExpression(call.getAggregation().getName().toLowerCase(), ExpressionPosition.UNKNOWN, args); }
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){
((RelExprContext)_localctx).e = FunctionCallFactory.createExpression((((RelExprContext)_localctx).cmpr!=null?((RelExprContext)_localctx).cmpr.getText():null), pos((((RelExprContext)_localctx).left!=null?(((RelExprContext)_localctx).left.start):null)), ((RelExprContext)_localctx).left.e, ((RelExprContext)_localctx).right.e);
match(CParen); ((FunctionCallContext)_localctx).e = FunctionCallFactory.createExpression((((FunctionCallContext)_localctx).Identifier!=null?((FunctionCallContext)_localctx).Identifier.getText():null), pos(((FunctionCallContext)_localctx).Identifier), (((FunctionCallContext)_localctx).exprList == null ? new ArrayList<>() : ((FunctionCallContext)_localctx).exprList.listE));
match(CParen); ((AnyValueCallContext)_localctx).e = FunctionCallFactory.createExpression((((AnyValueCallContext)_localctx).AnyValue!=null?((AnyValueCallContext)_localctx).AnyValue.getText():null), pos(((AnyValueCallContext)_localctx).AnyValue), (((AnyValueCallContext)_localctx).exprList == null ? new ArrayList<>() : ((AnyValueCallContext)_localctx).exprList.listE));
case IS_FALSE: case OTHER: return FunctionCallFactory.createExpression(call.getOperator().getName().toLowerCase(), ExpressionPosition.UNKNOWN, call.getOperands().get(0).accept(this)); switch(call.getKind()){ case NOT: return FunctionCallFactory.createExpression(call.getOperator().getName().toLowerCase(), ExpressionPosition.UNKNOWN, arg); case MINUS_PREFIX: List<LogicalExpression> operands = Lists.newArrayList(); operands.add(call.getOperands().get(0).accept(this)); return FunctionCallFactory.createExpression("u-", operands);
setState(389); ((UnaryExprContext)_localctx).atom = atom(); ((UnaryExprContext)_localctx).e = FunctionCallFactory.createExpression("u-", pos(((UnaryExprContext)_localctx).Minus), ((UnaryExprContext)_localctx).atom.e); setState(393); ((UnaryExprContext)_localctx).atom = atom(); ((UnaryExprContext)_localctx).e = FunctionCallFactory.createExpression("!", pos(((UnaryExprContext)_localctx).Excl), ((UnaryExprContext)_localctx).atom.e);