@Override public RexNode visitLiteral(RexLiteral literal) { // Use nullIndicator to decide whether to project null. // Do nothing if the literal is null. if (!RexUtil.isNull(literal) && projectPulledAboveLeftCorrelator && (nullIndicator != null)) { return createCaseExpression( nullIndicator, rexBuilder.constantNull(), literal); } return literal; }
@Override public RexNode visitLiteral(RexLiteral literal) { // Use nullIndicator to decide whether to project null. // Do nothing if the literal is null. if (!RexUtil.isNull(literal) && projectPulledAboveLeftCorrelator && (nullIndicator != null)) { return createCaseExpression( nullIndicator, rexBuilder.constantNull(), literal); } return literal; }
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { if (cm.mapFieldAccessToCorRef.containsKey(fieldAccess)) { // if it is a corVar, change it to be input ref. CorRef corVar = cm.mapFieldAccessToCorRef.get(fieldAccess); // corVar offset should point to the leftInput of currentRel, // which is the Correlator. RexNode newRexNode = new RexInputRef(corVar.field, fieldAccess.getType()); if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) { // need to enforce nullability by applying an additional // cast operator over the transformed expression. newRexNode = createCaseExpression( nullIndicator, rexBuilder.constantNull(), newRexNode); } return newRexNode; } return fieldAccess; }
@Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { if (cm.mapFieldAccessToCorRef.containsKey(fieldAccess)) { // if it is a corVar, change it to be input ref. CorRef corVar = cm.mapFieldAccessToCorRef.get(fieldAccess); // corVar offset should point to the leftInput of currentRel, // which is the Correlator. RexNode newRexNode = new RexInputRef(corVar.field, fieldAccess.getType()); if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) { // need to enforce nullability by applying an additional // cast operator over the transformed expression. newRexNode = createCaseExpression( nullIndicator, rexBuilder.constantNull(), newRexNode); } return newRexNode; } return fieldAccess; }
/** Creates a literal (constant expression). */ public RexNode literal(Object value) { final RexBuilder rexBuilder = cluster.getRexBuilder(); if (value == null) { return rexBuilder.constantNull(); } else if (value instanceof Boolean) { return rexBuilder.makeLiteral((Boolean) value); } else if (value instanceof BigDecimal) { return rexBuilder.makeExactLiteral((BigDecimal) value); } else if (value instanceof Float || value instanceof Double) { return rexBuilder.makeApproxLiteral( BigDecimal.valueOf(((Number) value).doubleValue())); } else if (value instanceof Number) { return rexBuilder.makeExactLiteral( BigDecimal.valueOf(((Number) value).longValue())); } else if (value instanceof String) { return rexBuilder.makeLiteral((String) value); } else { throw new IllegalArgumentException("cannot convert " + value + " (" + value.getClass() + ") to a constant"); } }
/** Creates a literal (constant expression). */ public RexNode literal(Object value) { final RexBuilder rexBuilder = cluster.getRexBuilder(); if (value == null) { return rexBuilder.constantNull(); } else if (value instanceof Boolean) { return rexBuilder.makeLiteral((Boolean) value); } else if (value instanceof BigDecimal) { return rexBuilder.makeExactLiteral((BigDecimal) value); } else if (value instanceof Float || value instanceof Double) { return rexBuilder.makeApproxLiteral( BigDecimal.valueOf(((Number) value).doubleValue())); } else if (value instanceof Number) { return rexBuilder.makeExactLiteral( BigDecimal.valueOf(((Number) value).longValue())); } else if (value instanceof String) { return rexBuilder.makeLiteral((String) value); } else { throw new IllegalArgumentException("cannot convert " + value + " (" + value.getClass() + ") to a constant"); } }
rexBuilder.makeExactLiteral(BigDecimal.ONE), rexBuilder.constantNull()); gbChildProjLst.add(when);
rexBuilder.ensureType( extraField.getType(), rexBuilder.constantNull(), true)); nameList.add(extraField.getName());
rexBuilder.ensureType( extraField.getType(), rexBuilder.constantNull(), true)); nameList.add(extraField.getName());
rexBuilder.makeExactLiteral(BigDecimal.ONE), rexBuilder.constantNull()); gbChildProjLst.add(when);
return createCaseExpression( nullIndicator, rexBuilder.constantNull(), newCall);
return createCaseExpression( nullIndicator, rexBuilder.constantNull(), newCall);
rexBuilder.makeExactLiteral(BigDecimal.ONE); final RexNode nul = rexBuilder.makeCast(countArg.getType(), rexBuilder.constantNull()); final RexNode countMinusOne = rexBuilder.makeCall(
public RexNode newAttributeInitializer(RelDataType type, SqlFunction constructor, int iAttribute, List<RexNode> constructorArgs, InitializerContext context) { return context.getRexBuilder().constantNull(); } }
public RexNode newAttributeInitializer(RelDataType type, SqlFunction constructor, int iAttribute, List<RexNode> constructorArgs, InitializerContext context) { return context.getRexBuilder().constantNull(); } }
public RexNode newColumnDefaultValue(RelOptTable table, int iColumn, InitializerContext context) { return context.getRexBuilder().constantNull(); }
public RexNode newColumnDefaultValue(RelOptTable table, int iColumn, InitializerContext context) { return context.getRexBuilder().constantNull(); }
@Override public RexNode visitLiteral(RexLiteral literal) { // Use nullIndicator to decide whether to project null. // Do nothing if the literal is null. if (!RexUtil.isNull(literal) && projectPulledAboveLeftCorrelator && (nullIndicator != null)) { return createCaseExpression( nullIndicator, rexBuilder.constantNull(), literal); } return literal; }
private void flattenNullLiteral( RelDataType type, List<Pair<RexNode, String>> flattenedExps) { RelDataType flattenedType = SqlTypeUtil.flattenRecordType(rexBuilder.getTypeFactory(), type, null); for (RelDataTypeField field : flattenedType.getFieldList()) { flattenedExps.add( Pair.of( rexBuilder.makeCast(field.getType(), rexBuilder.constantNull()), field.getName())); } }
private void flattenNullLiteral( RelDataType type, List<Pair<RexNode, String>> flattenedExps) { RelDataType flattenedType = SqlTypeUtil.flattenRecordType(rexBuilder.getTypeFactory(), type, null); for (RelDataTypeField field : flattenedType.getFieldList()) { flattenedExps.add( Pair.of( rexBuilder.makeCast(field.getType(), rexBuilder.constantNull()), field.getName())); } }