You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by ji...@apache.org on 2018/02/26 19:16:21 UTC

[40/46] incubator-quickstep git commit: Fixed the bug when partition w/ pruned columns.

Fixed the bug when partition w/ pruned columns.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/d6347724
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/d6347724
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/d6347724

Branch: refs/heads/fix-iwyu
Commit: d63477247648a45b577be27db57954f9e85454c3
Parents: d886ddb
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Tue Oct 24 16:17:50 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Thu Dec 21 15:28:38 2017 -0600

----------------------------------------------------------------------
 query_optimizer/ExecutionGenerator.cpp          | 39 ++++++++++----------
 .../tests/execution_generator/Partition.test    | 25 +------------
 2 files changed, 20 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d6347724/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 5ef58a9..555118a 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -486,26 +486,8 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
     const P::PhysicalPtr &physical,
     const CatalogRelation **catalog_relation_output,
     S::InsertDestination *insert_destination_proto) {
-  std::unique_ptr<CatalogRelation> catalog_relation(
-      new CatalogRelation(catalog_database_,
-                          getNewRelationName(),
-                          -1 /* id */,
-                          true /* is_temporary*/));
-  attribute_id aid = 0;
-  for (const E::NamedExpressionPtr &project_expression :
-       physical->getOutputAttributes()) {
-    // The attribute name is simply set to the attribute id to make it distinct.
-    std::unique_ptr<CatalogAttribute> catalog_attribute(
-        new CatalogAttribute(catalog_relation.get(),
-                             std::to_string(aid),
-                             project_expression->getValueType(),
-                             aid,
-                             project_expression->attribute_alias()));
-    attribute_substitution_map_[project_expression->id()] =
-        catalog_attribute.get();
-    catalog_relation->addAttribute(catalog_attribute.release());
-    ++aid;
-  }
+  auto catalog_relation =
+      make_unique<CatalogRelation>(catalog_database_, getNewRelationName(), -1 /* id */, true /* is_temporary*/);
 
   const P::PartitionSchemeHeader *partition_scheme_header = physical->getOutputPartitionSchemeHeader();
   if (partition_scheme_header) {
@@ -514,6 +496,9 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
       DCHECK(!partition_equivalent_expr_ids.empty());
       const E::ExprId partition_expr_id = *partition_equivalent_expr_ids.begin();
       DCHECK(attribute_substitution_map_.find(partition_expr_id) != attribute_substitution_map_.end());
+      // Use the attribute id from the input relation.
+      // NOTE(zuyu): The following line should be before changing
+      // 'attribute_substitution_map_' with the output attributes.
       output_partition_attr_ids.push_back(attribute_substitution_map_[partition_expr_id]->getID());
     }
 
@@ -544,6 +529,20 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
     insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
   }
 
+  attribute_id aid = 0;
+  for (const E::NamedExpressionPtr &project_expression :
+       physical->getOutputAttributes()) {
+    // The attribute name is simply set to the attribute id to make it distinct.
+    auto catalog_attribute =
+        make_unique<CatalogAttribute>(catalog_relation.get(), std::to_string(aid),
+                                      project_expression->getValueType(), aid,
+                                      project_expression->attribute_alias());
+    attribute_substitution_map_[project_expression->id()] =
+        catalog_attribute.get();
+    catalog_relation->addAttribute(catalog_attribute.release());
+    ++aid;
+  }
+
   *catalog_relation_output = catalog_relation.get();
   const relation_id output_rel_id = catalog_database_->addRelation(
       catalog_relation.release());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d6347724/query_optimizer/tests/execution_generator/Partition.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Partition.test b/query_optimizer/tests/execution_generator/Partition.test
index da9b6b8..747b969 100644
--- a/query_optimizer/tests/execution_generator/Partition.test
+++ b/query_optimizer/tests/execution_generator/Partition.test
@@ -297,30 +297,7 @@ SELECT dim_2_hash_partitions.id as dim_id, fact.id as fact_id
 FROM dim_2_hash_partitions, fact
 WHERE dim_2_hash_partitions.id > 20 AND fact.id > 0;
 --
-+-----------+-----------+
-|dim_id     |fact_id    |
-+-----------+-----------+
-|         24|          4|
-|         24|          8|
-|         24|         12|
-|         24|         16|
-|         24|         24|
-|         22|          4|
-|         22|          8|
-|         22|         12|
-|         22|         16|
-|         22|         24|
-|         24|          2|
-|         24|          6|
-|         24|         14|
-|         24|         18|
-|         24|         22|
-|         22|          2|
-|         22|          6|
-|         22|         14|
-|         22|         18|
-|         22|         22|
-+-----------+-----------+
+[same as above]
 ==
 
 SELECT id, int_col