/** * Creates a projection that converts the current relational expression's * output to a desired row type. * * @param castRowType row type after cast * @param rename if true, use field names from castRowType; if false, * preserve field names from rel */ public HiveSubQRemoveRelBuilder convert(RelDataType castRowType, boolean rename) { final RelNode r = build(); final RelNode r2 = RelOptUtil.createCastRel(r, castRowType, rename, projectFactory); push(r2); return this; }
/** * Creates a projection that converts the current relational expression's * output to a desired row type. * * @param castRowType row type after cast * @param rename if true, use field names from castRowType; if false, * preserve field names from rel */ public HiveSubQRemoveRelBuilder convert(RelDataType castRowType, boolean rename) { final RelNode r = build(); final RelNode r2 = RelOptUtil.createCastRel(r, castRowType, rename, projectFactory); push(r2); return this; }
/** * Creates a projection which casts a rel's output to a desired row type. * * @param rel producer of rows to be converted * @param castRowType row type after cast * @param rename if true, use field names from castRowType; if false, * preserve field names from rel * @return conversion rel */ public static RelNode createCastRel( final RelNode rel, RelDataType castRowType, boolean rename) { return createCastRel( rel, castRowType, rename, RelFactories.DEFAULT_PROJECT_FACTORY); }
/** * Creates a projection which casts a rel's output to a desired row type. * * @param rel producer of rows to be converted * @param castRowType row type after cast * @param rename if true, use field names from castRowType; if false, * preserve field names from rel * @return conversion rel */ public static RelNode createCastRel( final RelNode rel, RelDataType castRowType, boolean rename) { return createCastRel( rel, castRowType, rename, RelFactories.DEFAULT_PROJECT_FACTORY); }
private RelRoot expandView(RelOptTable.ToRelContext preparingStmt, RelDataType rowType, String queryString) { try { RelRoot root = preparingStmt.expandView(rowType, queryString, schemaPath, viewPath); root = root.withRel(RelOptUtil.createCastRel(root.rel, rowType, true)); return root; } catch (Exception e) { throw new RuntimeException("Error while parsing view definition: " + queryString, e); } } }
/** * Creates a projection that converts the current relational expression's * output to a desired row type. * * @param castRowType row type after cast * @param rename if true, use field names from castRowType; if false, * preserve field names from rel */ public RelBuilder convert(RelDataType castRowType, boolean rename) { final RelNode r = build(); final RelNode r2 = RelOptUtil.createCastRel(r, castRowType, rename, projectFactory); push(r2); return this; }
/** * Creates a projection that converts the current relational expression's * output to a desired row type. * * @param castRowType row type after cast * @param rename if true, use field names from castRowType; if false, * preserve field names from rel */ public RelBuilder convert(RelDataType castRowType, boolean rename) { final RelNode r = build(); final RelNode r2 = RelOptUtil.createCastRel(r, castRowType, rename, projectFactory); push(r2); return this; }
/** * Creates a RelOptMaterialization. */ public RelOptMaterialization(RelNode tableRel, RelNode queryRel, RelOptTable starRelOptTable, List<String> qualifiedTableName) { this.tableRel = RelOptUtil.createCastRel(tableRel, queryRel.getRowType(), false); this.starRelOptTable = starRelOptTable; if (starRelOptTable == null) { this.starTable = null; } else { this.starTable = starRelOptTable.unwrap(StarTable.class); assert starTable != null; } this.qualifiedTableName = qualifiedTableName; this.queryRel = queryRel; }
/** * Creates a RelOptMaterialization. */ public RelOptMaterialization(RelNode tableRel, RelNode queryRel, RelOptTable starRelOptTable, List<String> qualifiedTableName) { this.tableRel = RelOptUtil.createCastRel(tableRel, queryRel.getRowType(), false); this.starRelOptTable = starRelOptTable; if (starRelOptTable == null) { this.starTable = null; } else { this.starTable = starRelOptTable.unwrap(StarTable.class); assert starTable != null; } this.qualifiedTableName = qualifiedTableName; this.queryRel = queryRel; }
private RelRoot expandView(RelOptTable.ToRelContext context, RelDataType rowType, String queryString) { try { final RelRoot root = context.expandView(rowType, queryString, schemaPath, viewPath); final RelNode rel = RelOptUtil.createCastRel(root.rel, rowType, true); // Expand any views final RelNode rel2 = rel.accept( new RelShuttleImpl() { @Override public RelNode visit(TableScan scan) { final RelOptTable table = scan.getTable(); final TranslatableTable translatableTable = table.unwrap(TranslatableTable.class); if (translatableTable != null) { return translatableTable.toRel(context, table); } return super.visit(scan); } }); return root.withRel(rel2); } catch (Exception e) { throw new RuntimeException("Error while parsing view definition: " + queryString, e); } } }
RelNode input = inputs.get(i); RelNode newInput = RelOptUtil.createCastRel( input, expectedType,
RelNode input = inputs.get(i); RelNode newInput = RelOptUtil.createCastRel( input, expectedType,
case 1: builder.push( RelOptUtil.createCastRel( newInputs.get(0), minus.getRowType(),
case 1: builder.push( RelOptUtil.createCastRel( newInputs.get(0), minus.getRowType(),
case 1: builder.push( RelOptUtil.createCastRel( newInputs.get(0), union.getRowType(),
case 1: builder.push( RelOptUtil.createCastRel( newInputs.get(0), union.getRowType(),
RelSubset subset = registerImpl(materialization.queryRel, null); RelNode tableRel2 = RelOptUtil.createCastRel( materialization.tableRel, materialization.queryRel.getRowType(),
RelSubset subset = registerImpl(materialization.queryRel, null); RelNode tableRel2 = RelOptUtil.createCastRel( materialization.tableRel, materialization.queryRel.getRowType(),
@Override public RelNode toRel(ToRelContext context, RelOptTable relOptTable) { ViewExpansionContext.ViewExpansionToken token = null; try { RelDataType rowType = relOptTable.getRowType(); RelNode rel; if (viewExpansionContext.isImpersonationEnabled()) { token = viewExpansionContext.reserveViewExpansionToken(viewOwner); rel = context.expandView(rowType, view.getSql(), token.getSchemaTree(), view.getWorkspaceSchemaPath()).rel; } else { rel = context.expandView(rowType, view.getSql(), view.getWorkspaceSchemaPath(), ImmutableList.<String>of()).rel; } // If the View's field list is not "*", create a cast. if (!view.isDynamic() && !view.hasStar()) { rel = RelOptUtil.createCastRel(rel, rowType, true); } return rel; } finally { if (token != null) { token.release(); } } }