use of org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableFunctionScan in project hive by apache.
the class HiveCalciteUtil method getTopLevelSelect.
/**
* Get top level select starting from root. Assumption here is root can only
* be Sort & Project. Also the top project should be at most 2 levels below
* Sort; i.e Sort(Limit)-Sort(OB)-Select
*
* @param rootRel
* @return
*/
public static Pair<RelNode, RelNode> getTopLevelSelect(final RelNode rootRel) {
RelNode tmpRel = rootRel;
RelNode parentOforiginalProjRel = rootRel;
RelNode originalProjRel = null;
while (tmpRel != null) {
if (tmpRel instanceof HiveProject || tmpRel instanceof HiveTableFunctionScan) {
originalProjRel = tmpRel;
break;
}
parentOforiginalProjRel = tmpRel;
tmpRel = tmpRel.getInput(0);
}
return (new Pair<RelNode, RelNode>(parentOforiginalProjRel, originalProjRel));
}
Aggregations