use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project hive by apache.
the class HiveSubQRemoveRelBuilder method values.
/**
* Creates a {@link Values} with a specified row type.
*
* <p>This method can handle cases that {@link #values(String[], Object...)}
* cannot, such as all values of a column being null, or there being zero
* rows.
*
* @param tupleList Tuple list
* @param rowType Row type
*/
public HiveSubQRemoveRelBuilder values(Iterable<? extends List<RexLiteral>> tupleList, RelDataType rowType) {
RelNode values = valuesFactory.createValues(cluster, rowType, copy(tupleList));
push(values);
return this;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project hive by apache.
the class HiveSubQRemoveRelBuilder method convert.
/**
* 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;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project drill by apache.
the class SqlConverter method toRel.
public RelRoot toRel(final SqlNode validatedNode) {
initCluster(initPlanner());
DrillViewExpander viewExpander = new DrillViewExpander(this);
final SqlToRelConverter sqlToRelConverter = new SqlToRelConverter(viewExpander, validator, catalog, cluster, DrillConvertletTable.INSTANCE, sqlToRelConverterConfig);
boolean topLevelQuery = !isInnerQuery || isExpandedView;
RelRoot rel = sqlToRelConverter.convertQuery(validatedNode, false, topLevelQuery);
// add another project to remove them.
if (topLevelQuery && rel.rel.getRowType().getFieldCount() - rel.fields.size() > 0) {
RexBuilder builder = rel.rel.getCluster().getRexBuilder();
RelNode relNode = rel.rel;
List<RexNode> expressions = rel.fields.stream().map(f -> builder.makeInputRef(relNode, f.left)).collect(Collectors.toList());
RelNode project = LogicalProject.create(rel.rel, expressions, rel.validatedRowType);
rel = RelRoot.of(project, rel.validatedRowType, rel.kind);
}
return rel.withRel(sqlToRelConverter.flattenTypes(rel.rel, true));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project drill by apache.
the class ExcessiveExchangeIdentifier method visitPrel.
@Override
public Prel visitPrel(Prel prel, MajorFragmentStat s) throws RuntimeException {
List<RelNode> children = Lists.newArrayList();
s.add(prel);
// consistent decision.
for (Prel p : prel) {
s.add(p);
}
s.setHashDistribution(prel);
for (Prel p : prel) {
children.add(p.accept(this, s));
}
if (children.equals(prel.getInputs())) {
return prel;
}
return (Prel) prel.copy(prel.getTraitSet(), children);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project drill by apache.
the class ExcessiveExchangeIdentifier method visitLateral.
@Override
public Prel visitLateral(LateralJoinPrel prel, MajorFragmentStat s) throws RuntimeException {
List<RelNode> children = Lists.newArrayList();
s.add(prel);
for (Prel p : prel) {
s.add(p);
}
// Traverse the left side of the Lateral join first. Left side of the
// Lateral shouldn't have any restrictions on Exchanges.
children.add(((Prel) prel.getInput(0)).accept(this, s));
// Save the outermost Lateral join so as to unset the flag later.
if (topMostLateralJoin == null) {
topMostLateralJoin = prel;
}
// Right side of the Lateral shouldn't have any Exchanges. Hence set the
// flag so that visitExchange removes the exchanges.
s.setRightSideOfLateral(true);
children.add(((Prel) prel.getInput(1)).accept(this, s));
if (topMostLateralJoin == prel) {
topMostLateralJoin = null;
s.setRightSideOfLateral(false);
}
if (children.equals(prel.getInputs())) {
return prel;
}
return (Prel) prel.copy(prel.getTraitSet(), children);
}
Aggregations