From 9cf7182c5c8a7cd2beb164cf069c8fb690e7bab3 Mon Sep 17 00:00:00 2001 From: Jesus Camacho Rodriguez Date: Wed, 15 Nov 2017 11:23:30 -0800 Subject: [PATCH] HIVE-18068 : Replace LocalInterval by Interval in Druid storage handler Signed-off-by: Ashutosh Chauhan --- pom.xml | 2 +- .../ql/metadata/HiveMaterializedViewsRegistry.java | 3 +-- .../ql/optimizer/calcite/HiveRelDistribution.java | 23 ++++++++++++++++++++++ .../hadoop/hive/ql/parse/CalcitePlanner.java | 3 +-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index edb38c9707..2670e56bcc 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ 1.10.0 1.7.7 0.8.0.RELEASE - 1.14.0 + 1.15.0-SNAPSHOT 4.2.4 4.1.17 4.1.19 diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java index 51b6ef58fc..09c58c368d 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMaterializedViewsRegistry.java @@ -311,8 +311,7 @@ private static RelNode createTableScan(Table viewTable) { } metrics.add(field.getName()); } - // TODO: Default interval will be an Interval once Calcite 1.15.0 is released. - // We will need to update the type of this list. + List intervals = Arrays.asList(DruidTable.DEFAULT_INTERVAL); DruidTable druidTable = new DruidTable(new DruidSchema(address, address, false), diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelDistribution.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelDistribution.java index 653f1c535c..7e5beee573 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelDistribution.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelDistribution.java @@ -19,6 +19,7 @@ import java.util.List; +import org.apache.calcite.plan.RelMultipleTrait; import org.apache.calcite.plan.RelOptPlanner; import org.apache.calcite.plan.RelTrait; import org.apache.calcite.plan.RelTraitDef; @@ -26,8 +27,13 @@ import org.apache.calcite.rel.RelDistributionTraitDef; import org.apache.calcite.util.mapping.Mappings.TargetMapping; +import com.google.common.collect.Ordering; + public class HiveRelDistribution implements RelDistribution { + private static final Ordering> ORDERING = + Ordering.natural().lexicographical(); + List keys; RelDistribution.Type type; @@ -77,4 +83,21 @@ public Type getType() { return type; } + @Override + public boolean isTop() { + return type == Type.ANY; + } + + @Override + public int compareTo(RelMultipleTrait o) { + final RelDistribution distribution = (RelDistribution) o; + if (type == distribution.getType() + && (type == Type.HASH_DISTRIBUTED + || type == Type.RANGE_DISTRIBUTED)) { + return ORDERING.compare(getKeys(), distribution.getKeys()); + } + + return type.compareTo(distribution.getType()); + } + } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java index 76c82e2606..bf9e37200b 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java @@ -2425,8 +2425,7 @@ private RelNode genTableLogicalPlan(String tableAlias, QB qb) throws SemanticExc } metrics.add(field.getName()); } - // TODO: Default interval will be an Interval once Calcite 1.15.0 is released. - // We will need to update the type of this list. + List intervals = Arrays.asList(DruidTable.DEFAULT_INTERVAL); DruidTable druidTable = new DruidTable(new DruidSchema(address, address, false), -- 2.13.6 (Apple Git-96)