Column rightExpr = EvalTreeUtil.findAllColumnRefs(joinCondition.getRightExpr()).get(0);
// 0 - left table, 1 - right table
String [] relationNames = new String[2];
NamedExprsManager namedExprsMgr = block.getNamedExprsManager();
if (leftExpr.hasQualifier()) {
relationNames[0] = leftExpr.getQualifier();
} else {
if (namedExprsMgr.isAliasedName(leftExpr.getSimpleName())) {
String columnName = namedExprsMgr.getOriginalName(leftExpr.getSimpleName());
String qualifier = CatalogUtil.extractQualifier(columnName);
relationNames[0] = qualifier;
} else {
throw new PlanningException("Cannot expect a referenced relation: " + leftExpr);
}
}
if (rightExpr.hasQualifier()) {
relationNames[1] = rightExpr.getQualifier();
} else {
if (namedExprsMgr.isAliasedName(rightExpr.getSimpleName())) {
String columnName = namedExprsMgr.getOriginalName(rightExpr.getSimpleName());
String qualifier = CatalogUtil.extractQualifier(columnName);
relationNames[1] = qualifier;
} else {
throw new PlanningException("Cannot expect a referenced relation: " + rightExpr);
}