public JdbcCalcRel( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, RexProgram program, int flags) { super(cluster, traitSet, child); assert getConvention() instanceof JdbcConvention; this.flags = flags; this.program = program; this.rowType = program.getOutputRowType(); }
public JdbcCalcRel( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, RexProgram program, int flags) { super(cluster, traitSet, child); assert getConvention() instanceof JdbcConvention; this.flags = flags; this.program = program; this.rowType = program.getOutputRowType(); }
public Split( List<Pair<Op, RexProgram>> list ) { this.list = list; /* assert filter == null || analyze( filter ).isPureFilter(); assert function == null || analyze( function ).isPureFunction(); assert constant == null || analyze( constant ).isPureConstant(); assert discard == null || analyze( discard ).isPureDiscard(); assert rename == null || analyze( rename ).isPureRename(); assert retain == null || analyze( retain ).isPureRetain(); */ Pair<Op, RexProgram> previous = null; for( Pair<Op, RexProgram> pair : list ) { if( previous != null ) assert previous.right.getOutputRowType().equals( pair.right.getInputRowType() ); previous = pair; } }
public EnumerableCalcRel( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, RexProgram program, int flags) { super(cluster, traitSet, child); assert getConvention() instanceof EnumerableConvention; assert !program.containsAggs(); this.flags = flags; this.program = program; this.rowType = program.getOutputRowType(); }
private static Pipe addRetain( RelOptCluster cluster, RexProgram program, Pipe pipe ) { Fields resultFields = createTypedFields( cluster, program.getOutputRowType(), false ); return new Retain( pipe, resultFields ); }
@Override public CalcRelBase copy( RelTraitSet traitSet, RelNode child, RexProgram program, List<RelCollation> collationList) { return new CalcRel( getCluster(), traitSet, child, program.getOutputRowType(), program, collationList); }
@Override public EnumerableCalcRel copy(RelTraitSet traitSet, RelNode child, RexProgram program, List<RelCollation> collationList) { // we do not need to copy program; it is immutable return new EnumerableCalcRel(getCluster(), traitSet, child, program.getOutputRowType(), program, collationList); }
public static RelDataType getOutputConstantsRowType( RexProgram program ) { RelDataType outputRowType = program.getOutputRowType(); List<RelDataTypeField> fields = new ArrayList<RelDataTypeField>(); List<RexLocalRef> projectList = program.getProjectList(); for( int i = 0; i < projectList.size(); i++ ) { RexLocalRef ref = projectList.get( i ); if( !program.isConstant( ref ) ) continue; fields.add( outputRowType.getFieldList().get( i ) ); } return new RelRecordType( fields ); }
public EnumerableCalcRel( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, RelDataType rowType, RexProgram program, List<RelCollation> collationList) { super(cluster, traitSet, child, rowType, program, collationList); assert getConvention() instanceof EnumerableConvention; assert !program.containsAggs(); this.program = program; this.rowType = program.getOutputRowType(); }
public boolean isIdentity() { if( program.getCondition() != null || !program.getInputRowType().equals( program.getOutputRowType() ) ) return false; for( int i = 0; i < program.getProjectList().size(); i++ ) { RexLocalRef ref = program.getProjectList().get( i ); if( ref.getIndex() != i ) return false; } return true; } }
private static boolean isOnlyRename( RexProgram program ) { final List<String> inputFieldNames = program.getInputRowType().getFieldNames(); final List<String> outputFieldNames = program.getOutputRowType().getFieldNames(); return inputFieldNames.size() == outputFieldNames.size() && unique( inputFieldNames ) && unique( outputFieldNames ) && !inputFieldNames.equals( outputFieldNames ); }
private static boolean isComplex( RexProgram program ) { final List<String> inputFieldNames = program.getInputRowType().getFieldNames(); final List<String> outputFieldNames = program.getOutputRowType().getFieldNames(); return !( inputFieldNames.size() == outputFieldNames.size() && unique( inputFieldNames ) && unique( outputFieldNames ) ); }
private static Pipe addRename( RelOptCluster cluster, RexProgram program, Pipe pipe ) { // We know that the input has unique field names, and the output has unique // field names. if( !unique( program.getInputRowType().getFieldNames() ) ) throw new AssertionError(); if( !unique( program.getOutputRowType().getFieldNames() ) ) throw new AssertionError(); final Permutation permutation = program.getPermutation(); if( permutation == null ) throw new AssertionError(); Fields incomingFields = createTypedFields( cluster, Mappings.apply( permutation.inverse(), program.getInputRowType().getFieldList() ), false ); Fields renameFields = createTypedFieldsSelector( cluster, program.getOutputRowType(), false ); return new Rename( pipe, incomingFields, renameFields ); }
private static RexProgram renameInputs( RexProgram program, RexBuilder rexBuilder, List<String> names ) { final RelDataType inputRowType = program.getInputRowType(); if( inputRowType.getFieldNames().equals( names ) ) return program; final RexProgramBuilder builder = RexProgramBuilder.create( rexBuilder, rexBuilder.getTypeFactory().createStructType( Pair.zip( names, RelOptUtil.getFieldTypeList( inputRowType ) ) ), program.getExprList(), program.getProjectList(), program.getCondition(), program.getOutputRowType(), false ); return builder.getProgram(); }
final RexLocalRef conditionRef = program.getCondition(); final List<RexNode> exprs = program.getExprList(); final RelDataType outputRowType = program.getOutputRowType(); return create( rexBuilder,
final RexLocalRef conditionRef = program.getCondition(); final List<RexNode> exprs = program.getExprList(); final RelDataType outputRowType = program.getOutputRowType(); return create( rexBuilder,
private static Pipe addFunction( RelOptCluster cluster, RexProgram program, Pipe pipe ) { final Fields incomingFields = createTypedFields( cluster, program.getInputRowType(), false ); BlockBuilder statements = new BlockBuilder(); List<Expression> expressionList = RexToLixTranslator.translateProjects( program, (JavaTypeFactory) cluster.getTypeFactory(), statements, new RexToLixTranslator.InputGetter() { public Expression field( BlockBuilder list, int index ) { final Type type = incomingFields.getType( index ); final String name = incomingFields.get( index ).toString(); return Expressions.parameter( type, name ); } } ); Expression record = Expressions.newArrayInit( Object.class, expressionList ); record = Expressions.new_( getConstructor(), record ); statements.add( Expressions.return_( null, record ) ); BlockStatement block = statements.toBlock(); String expression = Expressions.toString( block ); Fields outgoingFields = createTypedFields( cluster, program.getOutputRowType(), false ); LOG.debug( "function parameters: {}", program.getInputRowType() ); LOG.debug( "function results: {}", outgoingFields ); LOG.debug( "function expression: {}", expression ); Function scriptFunction = new ScriptTupleFunction( outgoingFields, expression, incomingFields.getTypesClasses() ); return new Each( pipe, scriptFunction, Fields.RESULTS ); }
program.getProjectList(), program.getCondition(), program.getOutputRowType(), shuttle, true); calcRel.getTraitSet(), calcRel.getChild(), newProgram.getOutputRowType(), newProgram, Collections.<RelCollation>emptyList());
program.getProjectList(), program.getCondition(), program.getOutputRowType(), shuttle, true); calcRel.getTraitSet(), calcRel.getChild(), newProgram.getOutputRowType(), newProgram, Collections.<RelCollation>emptyList());
program.getOutputRowType(), "declared rowtype of rel", rowType,