inner-1519 (#3000)

* inner-1519

* subquery contains only one table
This commit is contained in:
Huqing Yan
2021-12-14 13:41:32 +08:00
committed by GitHub
parent 646900c585
commit 26a4e5c862

View File

@@ -665,19 +665,34 @@ public class JoinChooser {
}
private ERTable getERKey(PlanNode tn, Item c) {
if (!(c instanceof ItemField))
return null;
if (tn.type() != PlanNode.PlanNodeType.TABLE && !PlanUtil.isERNode(tn)) {
return null;
private boolean onlyContainsOneTable(PlanNode queryNode) {
PlanNode child = queryNode.getChildren().get(0);
if (child.type() == PlanNode.PlanNodeType.TABLE) {
return true;
} else if (child.type() == PlanNode.PlanNodeType.QUERY) {
return onlyContainsOneTable(child);
} else {
return false;
}
}
private ERTable getERKey(PlanNode tn, Item column) {
if (!(column instanceof ItemField))
return null;
Pair<TableNode, ItemField> pair = null;
if (tn.type() == PlanNode.PlanNodeType.QUERY && onlyContainsOneTable(tn)) {
pair = PlanUtil.findColumnInTableLeaf((ItemField) column, tn);
} else if (tn.type() != PlanNode.PlanNodeType.TABLE && !PlanUtil.isERNode(tn)) {
return null;
} else {
pair = PlanUtil.findColumnInTableLeaf((ItemField) column, tn);
}
Pair<TableNode, ItemField> pair = PlanUtil.findColumnInTableLeaf((ItemField) c, tn);
if (pair == null)
return null;
TableNode tableNode = pair.getKey();
ItemField col = pair.getValue();
ERTable erTable = new ERTable(tableNode.getSchema(), tableNode.getPureName(), col.getItemName());
if (tn.type() == PlanNode.PlanNodeType.TABLE) {
if (tn.type() == PlanNode.PlanNodeType.TABLE || tn.type() == PlanNode.PlanNodeType.QUERY) {
return erTable;
} else {
List<ERTable> erList = ((JoinNode) tn).getERkeys();