This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch beyyes/join
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/beyyes/join by this push:
new dddbf1f6d5a add aliased relation support
dddbf1f6d5a is described below
commit dddbf1f6d5a68f9fc1d55a7b16195e0eb84a8b17
Author: Beyyes <[email protected]>
AuthorDate: Mon Aug 12 15:26:02 2024 +0800
add aliased relation support
---
.../plan/relational/planner/RelationPlanner.java | 28 ++++++++++++++++++----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/RelationPlanner.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/RelationPlanner.java
index 7c44cccc88f..1d9e4c51f96 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/RelationPlanner.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/RelationPlanner.java
@@ -447,6 +447,29 @@ public class RelationPlanner extends
AstVisitor<RelationPlan, Void> {
&& ((ComparisonExpression) conjunct).getOperator() ==
ComparisonExpression.Operator.EQUAL;
}
+ @Override
+ protected RelationPlan visitAliasedRelation(AliasedRelation node, Void
context) {
+ RelationPlan subPlan = process(node.getRelation(), context);
+
+ PlanNode root = subPlan.getRoot();
+ List<Symbol> mappings = subPlan.getFieldMappings();
+
+ if (node.getColumnNames() != null) {
+ ImmutableList.Builder<Symbol> newMappings = ImmutableList.builder();
+
+ // Adjust the mappings to expose only the columns visible in the scope
of the aliased relation
+ for (int i = 0; i < subPlan.getDescriptor().getAllFieldCount(); i++) {
+ if (!subPlan.getDescriptor().getFieldByIndex(i).isHidden()) {
+ newMappings.add(subPlan.getFieldMappings().get(i));
+ }
+ }
+
+ mappings = newMappings.build();
+ }
+
+ return new RelationPlan(root, analysis.getScope(node), mappings);
+ }
+
// ================================ Implemented later
=====================================
@Override
@@ -459,11 +482,6 @@ public class RelationPlanner extends
AstVisitor<RelationPlan, Void> {
throw new IllegalStateException("SubqueryExpression is not supported in
current version.");
}
- @Override
- protected RelationPlan visitAliasedRelation(AliasedRelation node, Void
context) {
- throw new IllegalStateException("AliasedRelation is not supported in
current version.");
- }
-
@Override
protected RelationPlan visitIntersect(Intersect node, Void context) {
throw new IllegalStateException("Intersect is not supported in current
version.");