Expressions.field(context, BuiltInMethod.CONTEXT_ROOT.field); final List<Expression> list = RexToLixTranslator.translateProjects(program, javaTypeFactory, builder, null, root, inputGetter, correlates); for (int i = 0; i < list.size(); i++) {
public List<Expression> translateList( List<RexNode> operandList, RexImpTable.NullAs nullAs) { return translateList(operandList, nullAs, EnumUtils.internalTypes(operandList)); }
public static Expression translateCondition(RexProgram program, JavaTypeFactory typeFactory, BlockBuilder list, InputGetter inputGetter, Function1<String, InputGetter> correlates, SqlConformance conformance) { if (program.getCondition() == null) { return RexImpTable.TRUE_EXPR; } final ParameterExpression root = DataContext.ROOT; RexToLixTranslator translator = new RexToLixTranslator(program, typeFactory, root, inputGetter, list, Collections.emptyMap(), new RexBuilder(typeFactory), conformance, null, null); translator = translator.setCorrelates(correlates); return translator.translate( program.getCondition(), RexImpTable.NullAs.FALSE); }
return handleNull(input, nullAs); case LOCAL_REF: return translate( deref(expr), nullAs, storageType); case LITERAL: return translateLiteral( (RexLiteral) expr, nullifyType( expr.getType(), isNullable(expr) && nullAs != RexImpTable.NullAs.NOT_POSSIBLE), typeFactory, nullAs); case DYNAMIC_PARAM: return translateParameter((RexDynamicParam) expr, nullAs, storageType); case CORREL_VARIABLE: throw new RuntimeException("Cannot translate " + expr + ". Correlated" case FIELD_ACCESS: RexFieldAccess fieldAccess = (RexFieldAccess) expr; RexNode target = deref(fieldAccess.getReferenceExpr()); default: if (expr instanceof RexCall) { return translateCall((RexCall) expr, nullAs);
return handleNullUnboxingIfNecessary(input, nullAs, storageType); return translate( deref(expr), nullAs, storageType); case LITERAL: return translateLiteral( (RexLiteral) expr, nullifyType( expr.getType(), isNullable(expr) && nullAs != RexImpTable.NullAs.NOT_POSSIBLE), typeFactory, nullAs); case DYNAMIC_PARAM: return translateParameter((RexDynamicParam) expr, nullAs, storageType); case CORREL_VARIABLE: throw new RuntimeException("Cannot translate " + expr + ". Correlated" case FIELD_ACCESS: { RexFieldAccess fieldAccess = (RexFieldAccess) expr; RexNode target = deref(fieldAccess.getReferenceExpr()); int fieldIndex = fieldAccess.getField().getIndex(); String fieldName = fieldAccess.getField().getName(); Expression y = getter.field(list, fieldIndex, storageType); Expression input = list.append("corInp" + fieldIndex + "_", y); // safe to share return handleNullUnboxingIfNecessary(input, nullAs, storageType);
"inputEnumerator"); Expression input = RexToLixTranslator.convert( Expressions.call( inputEnumerator, final BlockBuilder builder2 = new BlockBuilder(); Expression condition = RexToLixTranslator.translateCondition( program, typeFactory, SqlConformanceEnum.DEFAULT); List<Expression> expressions = RexToLixTranslator.translateProjects( program, typeFactory,
private static Expression implementCall( final RexToLixTranslator translator, RexCall call, NotNullImplementor implementor, final NullAs nullAs) { List<Expression> translatedOperands = translator.translateList(call.getOperands()); // Make sure the operands marked not null in the translator have all been // handled for nulls before being passed to the NotNullImplementor. if (nullAs == NullAs.NOT_POSSIBLE) { List<Expression> nullHandled = translatedOperands; for (int i = 0; i < translatedOperands.size(); i++) { RexNode arg = call.getOperands().get(i); Expression e = translatedOperands.get(i); if (!translator.isNullable(arg)) { if (nullHandled == translatedOperands) { nullHandled = new ArrayList<>(translatedOperands.subList(0, i)); } nullHandled.add(translator.handleNull(e, nullAs)); } else if (nullHandled != translatedOperands) { nullHandled.add(e); } } translatedOperands = nullHandled; } Expression result = implementor.implement(translator, call, translatedOperands); return translator.handleNull(result, nullAs); }
return new RexToLixTranslator(program, typeFactory, root, inputGetter, list, Collections.emptyMap(), new RexBuilder(typeFactory), conformance, null, null) .setCorrelates(correlates) .translateList(program.getProjectList(), storageTypes);
final List<Expression> conditions = new ArrayList<>(); conditions.addAll( translator.translateList(args, RexImpTable.NullAs.IS_NOT_NULL)); if (add.rexFilterArgument() != null) { conditions.add( translator.translate(add.rexFilterArgument(), RexImpTable.NullAs.FALSE)); if (translator.isNullable(arg)) { nullables.put(arg, false);
public Expression implement(RexToLixTranslator translator, RexCall call, NullAs nullAs) { // Short-circuit if no cast is required RexNode arg = call.getOperands().get(0); if (call.getType().equals(arg.getType())) { // No cast required, omit cast return translator.translate(arg, nullAs); } if (SqlTypeUtil.equalSansNullability(translator.typeFactory, call.getType(), arg.getType()) && nullAs == NullAs.NULL && translator.deref(arg) instanceof RexLiteral) { return RexToLixTranslator.translateLiteral( (RexLiteral) translator.deref(arg), call.getType(), translator.typeFactory, nullAs); } return accurate.implement(translator, call, nullAs); } }
for (RexLiteral constant : constants) { translatedConstants.add( RexToLixTranslator.translateLiteral(constant, constant.getType(), typeFactory, RexImpTable.NullAs.NULL)); builder4.append( "row", RexToLixTranslator.convert( Expressions.arrayIndex(rows_, i_), inputPhysType.getJavaRowType())); RexToLixTranslator.forAggregation(typeFactory, builder4, inputGetter, implementor.getConformance());
public static Expression convert(Expression operand, Type toType) { final Type fromType = operand.getType(); return convert(operand, fromType, toType); }
public Expression implement(RexToLixTranslator translator, RexCall call, NullAs nullAs) { switch (nullAs) { case NULL: return Expressions.call(BuiltInMethod.NOT.method, translator.translateList(call.getOperands(), nullAs)); default: return Expressions.not( translator.translate(call.getOperands().get(0), negate(nullAs))); } }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { BlockBuilder bb = new BlockBuilder(); // Non-array user-specified types are not supported yet final JavaRowFormat format; if (getElementType() == null) { format = JavaRowFormat.ARRAY; } else if (rowType.getFieldCount() == 1 && isQueryable()) { format = JavaRowFormat.SCALAR; } else if (getElementType() instanceof Class && Object[].class.isAssignableFrom((Class) getElementType())) { format = JavaRowFormat.ARRAY; } else { format = JavaRowFormat.CUSTOM; } final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), format, false); RexToLixTranslator t = RexToLixTranslator.forAggregation( (JavaTypeFactory) getCluster().getTypeFactory(), bb, null, implementor.getConformance()); t = t.setCorrelates(implementor.allCorrelateVariables); bb.add(Expressions.return_(null, t.translate(getCall()))); return implementor.result(physType, bb.toBlock()); }
public RexToLixTranslator rowTranslator() { final SqlConformance conformance = SqlConformanceEnum.DEFAULT; // TODO: get this from implementor return RexToLixTranslator.forAggregation(typeFactory, currentBlock(), new RexToLixTranslator.InputGetterImpl( Collections.singletonList( Pair.of((Expression) inParameter, inputPhysType))), conformance) .setNullable(currentNullables()); } };
public RexToLixTranslator setBlock(BlockBuilder block) { if (block == list) { return this; } return new RexToLixTranslator(program, typeFactory, root, inputGetter, block, ImmutableMap.of(), builder, conformance, this, correlates); }
Expression offs = translator.translate(node); offs = RexToLixTranslator.convert(offs, int.class); desiredKeyType = Primitive.box(desiredKeyType); Expression val = translator.translate( new RexInputRef(orderKey, keyType), desiredKeyType); if (!bound.isCurrentRow()) { RexNode node = bound.getOffset(); Expression offs = translator.translate(node);
convert = convert(operand, typeFactory.getJavaClass(targetType)); return scaleIntervalToNumber(sourceType, targetType, convert);
@Override public String visitLiteral(RexLiteral literal) { if (literal.getValue() == null) { return "null"; } return "\"literal\":\"" + RexToLixTranslator.translateLiteral(literal, literal.getType(), typeFactory, RexImpTable.NullAs.NOT_POSSIBLE) + "\""; }
BuiltInMethod.TIMESTAMP_WITH_LOCAL_TIME_ZONE_TO_TIMESTAMP.method, operand, Expressions.call(BuiltInMethod.TIME_ZONE.method, translator.getRoot()));