You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by re...@apache.org on 2017/07/17 18:28:24 UTC
hive git commit: HIVE-17019 Remove calls to
RelMetadataQuery.instance() after Calcite 1.13 upgrade (RemusR,
reviewed by AshutoshC)
Repository: hive
Updated Branches:
refs/heads/master 1fe8db618 -> e7081035b
HIVE-17019 Remove calls to RelMetadataQuery.instance() after Calcite 1.13 upgrade (RemusR, reviewed by AshutoshC)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e7081035
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e7081035
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e7081035
Branch: refs/heads/master
Commit: e7081035bb9768bc014f0aba11417418ececbaf0
Parents: 1fe8db6
Author: Remus Rusanu <re...@apache.org>
Authored: Mon Jul 17 11:28:09 2017 -0700
Committer: Remus Rusanu <re...@apache.org>
Committed: Mon Jul 17 11:28:09 2017 -0700
----------------------------------------------------------------------
.../ql/optimizer/calcite/HiveCalciteUtil.java | 3 +-
.../calcite/cost/HiveAlgorithmsUtil.java | 10 +++---
.../calcite/cost/HiveDefaultCostModel.java | 2 +-
.../calcite/cost/HiveOnTezCostModel.java | 35 +++++++++++---------
.../calcite/reloperators/HiveAggregate.java | 3 +-
.../calcite/reloperators/HiveJoin.java | 5 +--
.../rules/HiveAggregateJoinTransposeRule.java | 2 +-
.../rules/HiveExpandDistinctAggregatesRule.java | 3 +-
.../rules/HiveFilterSetOpTransposeRule.java | 2 +-
.../HiveJoinPushTransitivePredicatesRule.java | 2 +-
.../rules/HiveReduceExpressionsRule.java | 2 +-
.../HiveReduceExpressionsWithStatsRule.java | 2 +-
.../calcite/rules/HiveRelDecorrelator.java | 6 ++--
.../calcite/rules/HiveRemoveSqCountCheck.java | 2 +-
.../calcite/rules/HiveSortJoinReduceRule.java | 3 +-
.../rules/HiveSortLimitPullUpConstantsRule.java | 2 +-
.../calcite/rules/HiveSortRemoveRule.java | 2 +-
.../calcite/rules/HiveSortUnionReduceRule.java | 2 +-
.../rules/HiveUnionPullUpConstantsRule.java | 2 +-
19 files changed, 50 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
index 5f34e8d..8428615 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java
@@ -684,7 +684,8 @@ public class HiveCalciteUtil {
// Note: this is the last step, trying to avoid the expensive call to the metadata provider
// if possible
Set<String> predicatesInSubtree = Sets.newHashSet();
- for (RexNode pred : RelMetadataQuery.instance().getPulledUpPredicates(inp).pulledUpPredicates) {
+ final RelMetadataQuery mq = inp.getCluster().getMetadataQuery();
+ for (RexNode pred : mq.getPulledUpPredicates(inp).pulledUpPredicates) {
predicatesInSubtree.add(pred.toString());
predicatesInSubtree.addAll(Lists.transform(RelOptUtil.conjunctions(pred), REX_STR_FN));
}
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveAlgorithmsUtil.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveAlgorithmsUtil.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveAlgorithmsUtil.java
index 28c7362..cb033a0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveAlgorithmsUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveAlgorithmsUtil.java
@@ -199,7 +199,8 @@ public class HiveAlgorithmsUtil {
}
public static boolean isFittingIntoMemory(Double maxSize, RelNode input, int buckets) {
- Double currentMemory = RelMetadataQuery.instance().cumulativeMemoryWithinPhase(input);
+ final RelMetadataQuery mq = input.getCluster().getMetadataQuery();
+ Double currentMemory = mq.cumulativeMemoryWithinPhase(input);
if (currentMemory != null) {
if(currentMemory / buckets > maxSize) {
return false;
@@ -310,7 +311,7 @@ public class HiveAlgorithmsUtil {
public static Double getJoinMemory(HiveJoin join, MapJoinStreamingRelation streamingSide) {
Double memory = 0.0;
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
if (streamingSide == MapJoinStreamingRelation.NONE ||
streamingSide == MapJoinStreamingRelation.RIGHT_RELATION) {
// Left side
@@ -338,7 +339,7 @@ public class HiveAlgorithmsUtil {
final Double maxSplitSize = join.getCluster().getPlanner().getContext().
unwrap(HiveAlgorithmsConf.class).getMaxSplitSize();
// We repartition: new number of splits
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
final Double averageRowSize = mq.getAverageRowSize(join);
final Double rowCount = mq.getRowCount(join);
if (averageRowSize == null || rowCount == null) {
@@ -358,7 +359,8 @@ public class HiveAlgorithmsUtil {
} else {
return null;
}
- return RelMetadataQuery.instance().splitCount(largeInput);
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
+ return mq.splitCount(largeInput);
}
}
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveDefaultCostModel.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveDefaultCostModel.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveDefaultCostModel.java
index 11b6aa3..b04492f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveDefaultCostModel.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveDefaultCostModel.java
@@ -85,7 +85,7 @@ public class HiveDefaultCostModel extends HiveCostModel {
@Override
public RelOptCost getCost(HiveJoin join) {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
double leftRCount = mq.getRowCount(join.getLeft());
double rightRCount = mq.getRowCount(join.getRight());
return HiveCost.FACTORY.makeCost(leftRCount + rightRCount, 0.0, 0.0);
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveOnTezCostModel.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveOnTezCostModel.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveOnTezCostModel.java
index 2dbfd8f..a2e656d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveOnTezCostModel.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveOnTezCostModel.java
@@ -87,7 +87,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
if (aggregate.isBucketedInput()) {
return HiveCost.FACTORY.makeZeroCost();
} else {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = aggregate.getCluster().getMetadataQuery();
// 1. Sum of input cardinalities
final Double rCount = mq.getRowCount(aggregate.getInput());
if (rCount == null) {
@@ -130,7 +130,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
@Override
public RelOptCost getCost(HiveJoin join) {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
// 1. Sum of input cardinalities
final Double leftRCount = mq.getRowCount(join.getLeft());
final Double rightRCount = mq.getRowCount(join.getRight());
@@ -189,9 +189,9 @@ public class HiveOnTezCostModel extends HiveCostModel {
JoinAlgorithm oldAlgo = join.getJoinAlgorithm();
join.setJoinAlgorithm(TezCommonJoinAlgorithm.INSTANCE);
- final Double memoryWithinPhase =
- RelMetadataQuery.instance().cumulativeMemoryWithinPhase(join);
- final Integer splitCount = RelMetadataQuery.instance().splitCount(join);
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
+ final Double memoryWithinPhase = mq.cumulativeMemoryWithinPhase(join);
+ final Integer splitCount = mq.splitCount(join);
join.setJoinAlgorithm(oldAlgo);
if (memoryWithinPhase == null || splitCount == null) {
@@ -241,7 +241,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
@Override
public RelOptCost getCost(HiveJoin join) {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
// 1. Sum of input cardinalities
final Double leftRCount = mq.getRowCount(join.getLeft());
final Double rightRCount = mq.getRowCount(join.getRight());
@@ -332,7 +332,8 @@ public class HiveOnTezCostModel extends HiveCostModel {
return null;
}
// If simple map join, the whole relation goes in memory
- return RelMetadataQuery.instance().cumulativeMemoryWithinPhase(inMemoryInput);
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
+ return mq.cumulativeMemoryWithinPhase(inMemoryInput);
}
@Override
@@ -363,6 +364,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
@Override
public boolean isExecutable(HiveJoin join) {
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
final Double maxMemory = join.getCluster().getPlanner().getContext().
unwrap(HiveAlgorithmsConf.class).getMaxMemory();
// Check streaming side
@@ -386,7 +388,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
// What we need is a way to get buckets not splits
JoinAlgorithm oldAlgo = join.getJoinAlgorithm();
join.setJoinAlgorithm(TezBucketJoinAlgorithm.INSTANCE);
- Integer buckets = RelMetadataQuery.instance().splitCount(smallInput);
+ Integer buckets = mq.splitCount(smallInput);
join.setJoinAlgorithm(oldAlgo);
if (buckets == null) {
@@ -398,7 +400,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
for (int i=0; i<join.getInputs().size(); i++) {
RelNode input = join.getInputs().get(i);
// Is bucketJoin possible? We need correct bucketing
- RelDistribution distribution = RelMetadataQuery.instance().distribution(input);
+ RelDistribution distribution = mq.distribution(input);
if (distribution.getType() != Type.HASH_DISTRIBUTED) {
return false;
}
@@ -411,7 +413,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
@Override
public RelOptCost getCost(HiveJoin join) {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
// 1. Sum of input cardinalities
final Double leftRCount = mq.getRowCount(join.getLeft());
final Double rightRCount = mq.getRowCount(join.getRight());
@@ -496,9 +498,9 @@ public class HiveOnTezCostModel extends HiveCostModel {
return null;
}
// If bucket map join, only a split goes in memory
- final Double memoryInput =
- RelMetadataQuery.instance().cumulativeMemoryWithinPhase(inMemoryInput);
- final Integer splitCount = RelMetadataQuery.instance().splitCount(inMemoryInput);
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
+ final Double memoryInput = mq.cumulativeMemoryWithinPhase(inMemoryInput);
+ final Integer splitCount = mq.splitCount(inMemoryInput);
if (memoryInput == null || splitCount == null) {
return null;
}
@@ -543,6 +545,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
ImmutableIntList.copyOf(
joinPredInfo.getProjsFromRightPartOfJoinKeysInChildSchema()));
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
for (int i=0; i<join.getInputs().size(); i++) {
RelNode input = join.getInputs().get(i);
// Is smbJoin possible? We need correct order
@@ -557,7 +560,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
return false;
}
// Is smbJoin possible? We need correct bucketing
- RelDistribution distribution = RelMetadataQuery.instance().distribution(input);
+ RelDistribution distribution = mq.distribution(input);
if (distribution.getType() != Type.HASH_DISTRIBUTED) {
return false;
}
@@ -570,7 +573,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
@Override
public RelOptCost getCost(HiveJoin join) {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
// 1. Sum of input cardinalities
final Double leftRCount = mq.getRowCount(join.getLeft());
final Double rightRCount = mq.getRowCount(join.getRight());
@@ -639,7 +642,7 @@ public class HiveOnTezCostModel extends HiveCostModel {
@Override
public Double getCumulativeMemoryWithinPhaseSplit(HiveJoin join) {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
// TODO: Split count is not same as no of buckets
JoinAlgorithm oldAlgo = join.getJoinAlgorithm();
join.setJoinAlgorithm(TezSMBJoinAlgorithm.INSTANCE);
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveAggregate.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveAggregate.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveAggregate.java
index e4c0cc5..fa51b4e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveAggregate.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveAggregate.java
@@ -70,7 +70,8 @@ public class HiveAggregate extends Aggregate implements HiveRelNode {
}
public boolean isBucketedInput() {
- return RelMetadataQuery.instance().distribution(this.getInput()).getKeys().
+ final RelMetadataQuery mq = this.getInput().getCluster().getMetadataQuery();
+ return mq.distribution(this.getInput()).getKeys().
containsAll(groupSet.asList());
}
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveJoin.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveJoin.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveJoin.java
index 5b67d9d..4c5a359 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveJoin.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveJoin.java
@@ -158,7 +158,7 @@ public class HiveJoin extends Join implements HiveRelNode {
}
public MapJoinStreamingRelation getStreamingSide() {
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ RelMetadataQuery mq = left.getCluster().getMetadataQuery();
Double leftInputSize = mq.memory(left);
Double rightInputSize = mq.memory(right);
if (leftInputSize == null && rightInputSize == null) {
@@ -200,9 +200,10 @@ public class HiveJoin extends Join implements HiveRelNode {
ImmutableIntList.copyOf(
joinPredInfo.getProjsFromRightPartOfJoinKeysInChildSchema()));
+ final RelMetadataQuery mq = this.left.getCluster().getMetadataQuery();
for (int i=0; i<this.getInputs().size(); i++) {
boolean correctOrderFound = RelCollations.contains(
- RelMetadataQuery.instance().collations(this.getInputs().get(i)),
+ mq.collations(this.getInputs().get(i)),
joinKeysInChildren.get(i));
if (correctOrderFound) {
sortedInputsBuilder.set(i);
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateJoinTransposeRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateJoinTransposeRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateJoinTransposeRule.java
index 87e755c..21b46cf 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateJoinTransposeRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateJoinTransposeRule.java
@@ -119,7 +119,7 @@ public class HiveAggregateJoinTransposeRule extends AggregateJoinTransposeRule {
}
// Do the columns used by the join appear in the output of the aggregate?
- RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
final ImmutableBitSet aggregateColumns = aggregate.getGroupSet();
final ImmutableBitSet keyColumns = keyColumns(aggregateColumns,
mq.getPulledUpPredicates(join).pulledUpPredicates);
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
index 9825e7e..81bb730 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveExpandDistinctAggregatesRule.java
@@ -162,9 +162,10 @@ public final class HiveExpandDistinctAggregatesRule extends RelOptRule {
// If all of the agg expressions are distinct and have the same
// arguments then we can use a more efficient form.
+ final RelMetadataQuery mq = call.getMetadataQuery();
if ((nonDistinctCount == 0) && (argListSets.size() == 1)) {
for (Integer arg : argListSets.iterator().next()) {
- Set<RelColumnOrigin> colOrigs = RelMetadataQuery.instance().getColumnOrigins(aggregate, arg);
+ Set<RelColumnOrigin> colOrigs = mq.getColumnOrigins(aggregate, arg);
if (null != colOrigs) {
for (RelColumnOrigin colOrig : colOrigs) {
RelOptHiveTable hiveTbl = (RelOptHiveTable)colOrig.getOriginTable();
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSetOpTransposeRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSetOpTransposeRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSetOpTransposeRule.java
index 8772d59..a5794f7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSetOpTransposeRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveFilterSetOpTransposeRule.java
@@ -107,7 +107,7 @@ public class HiveFilterSetOpTransposeRule extends FilterSetOpTransposeRule {
RexNode newCondition = condition.accept(new RelOptUtil.RexInputConverter(rexBuilder,
origFields, input.getRowType().getFieldList(), adjustments));
if (setOp instanceof Union && setOp.all) {
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
final RelOptPredicateList predicates = mq.getPulledUpPredicates(input);
if (predicates != null) {
ImmutableList.Builder<RexNode> listBuilder = ImmutableList.builder();
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinPushTransitivePredicatesRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinPushTransitivePredicatesRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinPushTransitivePredicatesRule.java
index 65a19e1..9cdc5e9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinPushTransitivePredicatesRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinPushTransitivePredicatesRule.java
@@ -80,7 +80,7 @@ public class HiveJoinPushTransitivePredicatesRule extends RelOptRule {
public void onMatch(RelOptRuleCall call) {
Join join = call.rel(0);
- RelOptPredicateList preds = RelMetadataQuery.instance().getPulledUpPredicates(join);
+ RelOptPredicateList preds = call.getMetadataQuery().getPulledUpPredicates(join);
HiveRulesRegistry registry = call.getPlanner().getContext().unwrap(HiveRulesRegistry.class);
assert registry != null;
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsRule.java
index 6efc731..9a5d8e2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsRule.java
@@ -109,7 +109,7 @@ public abstract class HiveReduceExpressionsRule extends ReduceExpressionsRule {
Lists.newArrayList(filter.getCondition());
RexNode newConditionExp;
boolean reduced;
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
final RelOptPredicateList predicates =
mq.getPulledUpPredicates(filter.getInput());
if (reduceExpressions(filter, expList, predicates, true)) {
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsWithStatsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsWithStatsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsWithStatsRule.java
index 0644f0c..6e900b3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsWithStatsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveReduceExpressionsWithStatsRule.java
@@ -82,7 +82,7 @@ public class HiveReduceExpressionsWithStatsRule extends RelOptRule {
final Filter filter = call.rel(0);
final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
- final RelMetadataQuery metadataProvider = RelMetadataQuery.instance();
+ final RelMetadataQuery metadataProvider = call.getMetadataQuery();
// 1. Recompose filter possibly by pulling out common elements from DNF
// expressions
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java
index ef50d9d..0fd3217 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java
@@ -2294,7 +2294,7 @@ public class HiveRelDecorrelator implements ReflectiveVisitor {
// The join filters out the nulls. So, it's ok if there are
// nulls in the join keys.
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
if (!RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq, right,
rightJoinKeys)) {
//SQL2REL_LOGGER.fine(rightJoinKeys.toString()
@@ -2509,7 +2509,7 @@ public class HiveRelDecorrelator implements ReflectiveVisitor {
// The join filters out the nulls. So, it's ok if there are
// nulls in the join keys.
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
if (!RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq, left,
correlatedInputRefJoinKeys)) {
//SQL2REL_LOGGER.fine(correlatedJoinKeys.toString()
@@ -2588,7 +2588,7 @@ public class HiveRelDecorrelator implements ReflectiveVisitor {
// leftInputRel contains unique keys
// i.e. each row is distinct and can group by on all the left
// fields
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
if (!RelMdUtil.areColumnsDefinitelyUnique(mq, left, allCols)) {
//SQL2REL_LOGGER.fine("There are no unique keys for " + left);
return;
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveSqCountCheck.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveSqCountCheck.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveSqCountCheck.java
index 7f3a4a4..30010dc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveSqCountCheck.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveSqCountCheck.java
@@ -111,7 +111,7 @@ public class HiveRemoveSqCountCheck extends RelOptRule {
final int groupCount = aggregate.getGroupCount();
final RexBuilder rexBuilder = aggregate.getCluster().getRexBuilder();
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
final RelOptPredicateList predicates =
mq.getPulledUpPredicates(aggregate.getInput());
if (predicates == null) {
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortJoinReduceRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortJoinReduceRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortJoinReduceRule.java
index 2f2297d..c15224d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortJoinReduceRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortJoinReduceRule.java
@@ -95,8 +95,9 @@ public class HiveSortJoinReduceRule extends RelOptRule {
// Finally, if we do not reduce the input size, we bail out
final int offset = sortLimit.offset == null ? 0 : RexLiteral.intValue(sortLimit.offset);
+ final RelMetadataQuery mq = call.getMetadataQuery();
if (offset + RexLiteral.intValue(sortLimit.fetch)
- >= RelMetadataQuery.instance().getRowCount(reducedInput)) {
+ >= mq.getRowCount(reducedInput)) {
return false;
}
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
index 54874e3..5ae960f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitPullUpConstantsRule.java
@@ -84,7 +84,7 @@ public class HiveSortLimitPullUpConstantsRule extends RelOptRule {
}
final RexBuilder rexBuilder = sort.getCluster().getRexBuilder();
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
final RelOptPredicateList predicates = mq.getPulledUpPredicates(sort.getInput());
if (predicates == null) {
return;
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortRemoveRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortRemoveRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortRemoveRule.java
index 573b75a..5d6aaf0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortRemoveRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortRemoveRule.java
@@ -59,7 +59,7 @@ public class HiveSortRemoveRule extends RelOptRule {
// Finally, if we do not reduce the size input enough, we bail out
int limit = RexLiteral.intValue(sortLimit.fetch);
- Double rowCount = RelMetadataQuery.instance().getRowCount(sortLimit.getInput());
+ Double rowCount = call.getMetadataQuery().getRowCount(sortLimit.getInput());
if (rowCount != null && limit <= reductionProportion * rowCount &&
rowCount - limit >= reductionTuples) {
return false;
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortUnionReduceRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortUnionReduceRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortUnionReduceRule.java
index 04b94c3..dd54bcb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortUnionReduceRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortUnionReduceRule.java
@@ -80,7 +80,7 @@ public class HiveSortUnionReduceRule extends RelOptRule {
final int offset = sort.offset == null ? 0 : RexLiteral.intValue(sort.offset);
for (RelNode input : union.getInputs()) {
// If we do not reduce the input size, we bail out
- if (RexLiteral.intValue(sort.fetch) + offset < RelMetadataQuery.instance().getRowCount(input)) {
+ if (RexLiteral.intValue(sort.fetch) + offset < call.getMetadataQuery().getRowCount(input)) {
finishPushSortPastUnion = false;
// Here we do some query rewrite. We first get the new fetchRN, which is
// a sum of offset and fetch.
http://git-wip-us.apache.org/repos/asf/hive/blob/e7081035/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
index 4f6c610..614f0fc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveUnionPullUpConstantsRule.java
@@ -76,7 +76,7 @@ public class HiveUnionPullUpConstantsRule extends RelOptRule {
}
final RexBuilder rexBuilder = union.getCluster().getRexBuilder();
- final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelMetadataQuery mq = call.getMetadataQuery();
final RelOptPredicateList predicates = mq.getPulledUpPredicates(union);
if (predicates == null) {
return;