use of org.apache.calcite.rel.RelCollation in project hive by apache.
the class HiveRelDecorrelator method decorrelateRel.
/**
* Rewrite Sort.
*
* @param rel Sort to be rewritten
*/
public Frame decorrelateRel(Sort rel) {
// Sort itself should not reference cor vars.
assert !cm.mapRefRelToCorRef.containsKey(rel);
// Sort only references field positions in collations field.
// The collations field in the newRel now need to refer to the
// new output positions in its input.
// Its output does not change the input ordering, so there's no
// need to call propagateExpr.
final RelNode oldInput = rel.getInput();
final Frame frame = getInvoke(oldInput, rel);
if (frame == null) {
// If input has not been rewritten, do not rewrite this rel.
return null;
}
final RelNode newInput = frame.r;
Mappings.TargetMapping mapping = Mappings.target(frame.oldToNewOutputs, oldInput.getRowType().getFieldCount(), newInput.getRowType().getFieldCount());
RelCollation oldCollation = rel.getCollation();
RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
final RelNode newSort = HiveSortLimit.create(newInput, newCollation, rel.offset, rel.fetch);
// Sort does not change input ordering
return register(rel, newSort, frame.oldToNewOutputs, frame.corDefOutputs);
}
use of org.apache.calcite.rel.RelCollation in project hive by apache.
the class HiveRelDecorrelator method decorrelateRel.
/**
* Rewrite Sort.
*
* @param rel Sort to be rewritten
*/
public Frame decorrelateRel(HiveSortLimit rel) {
// Sort itself should not reference cor vars.
assert !cm.mapRefRelToCorRef.containsKey(rel);
// Sort only references field positions in collations field.
// The collations field in the newRel now need to refer to the
// new output positions in its input.
// Its output does not change the input ordering, so there's no
// need to call propagateExpr.
final RelNode oldInput = rel.getInput();
final Frame frame = getInvoke(oldInput, rel);
if (frame == null) {
// If input has not been rewritten, do not rewrite this rel.
return null;
}
final RelNode newInput = frame.r;
Mappings.TargetMapping mapping = Mappings.target(frame.oldToNewOutputs, oldInput.getRowType().getFieldCount(), newInput.getRowType().getFieldCount());
RelCollation oldCollation = rel.getCollation();
RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
final RelNode newSort = HiveSortLimit.create(newInput, newCollation, rel.offset, rel.fetch);
// Sort does not change input ordering
return register(rel, newSort, frame.oldToNewOutputs, frame.corDefOutputs);
}
Aggregations