private Expression createUnionExpression(Expression left, Expression right, boolean arrayInput) { if (all) { return Expressions.call(left, BuiltInMethod.CONCAT.method, right); } return arrayInput ? Expressions.call(left, unionArray, right, Expressions.call(arrayComparer)) : Expressions.call(left, BuiltInMethod.UNION.method, right); }
builder.add( Expressions.statement( Expressions.call( Expressions.parameter(ExecutableExpression.class, "this"), StormBuiltInMethod.EXPR_EXECUTE2.method, context, values_)));
@Override public Result implement(EnumerableRelImplementor implementor, Prefer pref) { PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), pref.preferArray()); return implementor.result(physType, Blocks.toBlock( Expressions.call(table.getExpression(FlowFileTable.class), "project", Expressions.constant(fields)))); }
@Override public Result implement(EnumerableRelImplementor implementor, Prefer pref) { context.setReturnTupleInfo(rowType, columnRowType); String execFunction = genExecFunc(); PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), JavaRowFormat.ARRAY); MethodCallExpression exprCall = Expressions.call(table.getExpression(OLAPTable.class), execFunction, implementor.getRootExpression(), Expressions.constant(context.id)); return implementor.result(physType, Blocks.toBlock(exprCall)); }
@Override public Result implement(EnumerableRelImplementor implementor, Prefer pref) { context.setReturnTupleInfo(rowType, columnRowType); PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), pref.preferArray()); RelOptTable factTable = context.firstTableScan.getTable(); MethodCallExpression exprCall = Expressions.call(factTable.getExpression(OLAPTable.class), "executeOLAPQuery", implementor.getRootExpression(), Expressions.constant(context.id)); return implementor.result(physType, Blocks.toBlock(exprCall)); }
public Expression implement( RexToLixTranslator translator, RexCall call, List<Expression> translatedOperands) { return Expressions.call( SqlFunctions.class, methodName, translatedOperands); } }
@Override public Expression getExpression(SchemaPlus parentSchema, String name) { return Expressions.call( DataContext.ROOT, BuiltInMethod.DATA_CONTEXT_GET_ROOT_SCHEMA.method); } }
public Expression implement( RexToLixTranslator translator, RexCall call, List<Expression> translatedOperands) { return Expressions.call( SqlFunctions.class, methodName, translatedOperands); } }
public Expression visit(MethodCallExpression methodCallExpression, Expression targetExpression, List<Expression> expressions) { return methodCallExpression.targetExpression == targetExpression && methodCallExpression.expressions.equals(expressions) ? methodCallExpression : Expressions.call(targetExpression, methodCallExpression.method, expressions); }
/** Normalizes a TIME value into 00:00:00..23:59:39. */ private Expression normalize(SqlTypeName typeName, Expression e) { switch (typeName) { case TIME: return Expressions.call(BuiltInMethod.FLOOR_MOD.method, e, Expressions.constant(DateTimeUtils.MILLIS_PER_DAY)); default: return e; } } }
@Override public Expression implementResult(AggContext info, AggResultContext result) { return Expressions.call(BuiltInMethod.JSONIZE.method, result.accumulator().get(0)); } }
/** * Creates a MethodCallExpression that represents a call to a * static method by calling the * appropriate factory method, using varargs. */ public static MethodCallExpression call(Type type, String methodName, Expression... arguments) { return call(type, methodName, toList(arguments)); }
/** Converts a schema expression to a given type by calling the * {@link SchemaPlus#unwrap(Class)} method. */ public static Expression unwrap(Expression call, Class type) { return Expressions.convert_( Expressions.call(call, BuiltInMethod.SCHEMA_PLUS_UNWRAP.method, Expressions.constant(type)), type); }
/** E.g. {@code constantArrayList("x", "y")} returns * "Arrays.asList('x', 'y')". * @param values list of values * @param clazz runtime class representing each element in the list * @param <T> type of elements in the list * @return method call which creates a list */ private static <T> MethodCallExpression constantArrayList(List<T> values, Class clazz) { return Expressions.call(BuiltInMethod.ARRAYS_AS_LIST.method, Expressions.newArrayInit(clazz, constantList(values))); }
public Expression field(Expression expression, int field, Type fromType, Type fieldType) { final MethodCallExpression e = Expressions.call(expression, BuiltInMethod.LIST_GET.method, Expressions.constant(field)); if (fromType == null) { fromType = e.getType(); } return RexToLixTranslator.convert(e, fromType, fieldType); } },
public Expression field(Expression expression, int field, Type fromType, Type fieldType) { final MethodCallExpression e = Expressions.call(expression, BuiltInMethod.LIST_GET.method, Expressions.constant(field)); if (fromType == null) { fromType = e.getType(); } return RexToLixTranslator.convert(e, fromType, fieldType); } },
private Expression call(Expression operand, Type type, TimeUnit timeUnit) { return Expressions.call(SqlFunctions.class, methodName, Types.castIfNecessary(type, operand), Types.castIfNecessary(type, Expressions.constant(timeUnit.multiplier))); } }
@Override public void implementNotNullAdd(AggContext info, AggAddContext add) { Expression acc = add.accumulator().get(0); Expression next; if (info.returnType() == BigDecimal.class) { next = Expressions.call(acc, "add", add.arguments().get(0)); } else { next = Expressions.add(acc, Types.castIfNecessary(acc.type, add.arguments().get(0))); } accAdvance(add, acc, next); }
public Expression convertTo(Expression exp, PhysType targetPhysType) { final JavaRowFormat targetFormat = targetPhysType.getFormat(); if (format == targetFormat) { return exp; } final ParameterExpression o_ = Expressions.parameter(javaRowClass, "o"); final int fieldCount = rowType.getFieldCount(); return Expressions.call(exp, BuiltInMethod.SELECT.method, generateSelector(o_, Util.range(fieldCount), targetFormat)); }
public Expression convertTo(Expression exp, PhysType targetPhysType) { final JavaRowFormat targetFormat = targetPhysType.getFormat(); if (format == targetFormat) { return exp; } final ParameterExpression o_ = Expressions.parameter(javaRowClass, "o"); final int fieldCount = rowType.getFieldCount(); return Expressions.call(exp, BuiltInMethod.SELECT.method, generateSelector(o_, Util.range(fieldCount), targetFormat)); }