use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelFieldCollation in project drill by axbaretto.
the class DrillSortRel method implement.
@Override
public LogicalOperator implement(DrillImplementor implementor) {
final Order.Builder builder = Order.builder();
builder.setInput(implementor.visitChild(this, 0, getInput()));
final List<String> childFields = getInput().getRowType().getFieldNames();
for (RelFieldCollation fieldCollation : this.collation.getFieldCollations()) {
builder.addOrdering(fieldCollation.getDirection(), new FieldReference(childFields.get(fieldCollation.getFieldIndex())), fieldCollation.nullDirection);
}
return builder.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelFieldCollation in project drill by axbaretto.
the class WindowPrule method getDistributionFieldsFromCollation.
private List<DistributionField> getDistributionFieldsFromCollation(Window.Group window) {
List<DistributionField> distFields = Lists.newArrayList();
for (RelFieldCollation relField : window.collation().getFieldCollations()) {
DistributionField field = new DistributionField(relField.getFieldIndex());
distFields.add(field);
}
return distFields;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelFieldCollation in project hive by apache.
the class ASTConverter method convertSortToASTNode.
private void convertSortToASTNode(HiveSortExchange hiveSortExchange) {
List<RelFieldCollation> fieldCollations = hiveSortExchange.getCollation().getFieldCollations();
convertFieldCollationsToASTNode(hiveSortExchange, new Schema(hiveSortExchange), fieldCollations, null, HiveParser.TOK_SORTBY, "TOK_SORTBY");
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelFieldCollation in project hive by apache.
the class ASTConverter method convertOrderLimitToASTNode.
private void convertOrderLimitToASTNode(HiveSortLimit hiveSortLimit) {
List<RelFieldCollation> fieldCollations = hiveSortLimit.getCollation().getFieldCollations();
convertFieldCollationsToASTNode(hiveSortLimit, new Schema(hiveSortLimit), fieldCollations, hiveSortLimit.getInputRefToCallMap(), HiveParser.TOK_ORDERBY, "TOK_ORDERBY");
RexNode offsetExpr = hiveSortLimit.getOffsetExpr();
RexNode fetchExpr = hiveSortLimit.getFetchExpr();
if (fetchExpr != null) {
Object offset = (offsetExpr == null) ? Integer.valueOf(0) : ((RexLiteral) offsetExpr).getValue2();
Object fetch = ((RexLiteral) fetchExpr).getValue2();
hiveAST.limit = ASTBuilder.limit(offset, fetch);
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelFieldCollation in project hive by apache.
the class HiveJdbcImplementor method visit.
@Override
public Result visit(Sort e) {
Result x = visitInput(e, 0, Clause.ORDER_BY, Clause.FETCH, Clause.OFFSET);
Builder builder = x.builder(e);
List<SqlNode> orderByList = Expressions.list();
for (RelFieldCollation field : e.getCollation().getFieldCollations()) {
builder.addOrderItem(orderByList, field);
}
// Create select list as we want to keep the column aliases
// instead of producing STAR
final List<SqlNode> selectList = new ArrayList<>();
for (int i = 0; i < e.getRowType().getFieldCount(); i++) {
RexInputRef ref = RexInputRef.of(i, e.getRowType());
SqlNode sqlExpr = builder.context.toSql(null, ref);
addSelect(selectList, sqlExpr, e.getRowType());
}
builder.setSelect(new SqlNodeList(selectList, POS));
if (!orderByList.isEmpty()) {
builder.setOrderBy(new SqlNodeList(orderByList, POS));
x = builder.result();
}
if (e.fetch != null) {
builder = x.builder(e);
builder.setFetch(builder.context.toSql(null, e.fetch));
x = builder.result();
}
if (e.offset != null) {
builder = x.builder(e);
builder.setOffset(builder.context.toSql(null, e.offset));
x = builder.result();
}
return x;
}
Aggregations