You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by xu...@apache.org on 2015/09/09 09:08:38 UTC
[08/50] [abbrv] hive git commit: HIVE-11623: CBO: Calcite Operator To
Hive Operator (Calcite Return Path): fix the tableAlias for ReduceSink
operator (Pengcheng Xiong, reviewed by Jesus Camacho Rodriguez)
HIVE-11623: CBO: Calcite Operator To Hive Operator (Calcite Return Path): fix the tableAlias for ReduceSink operator (Pengcheng Xiong, reviewed by Jesus Camacho Rodriguez)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/9e85bbf2
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/9e85bbf2
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/9e85bbf2
Branch: refs/heads/beeline-cli
Commit: 9e85bbf2780510edda79c247248da57619530577
Parents: fb152e4
Author: Pengcheng Xiong <px...@apache.org>
Authored: Thu Aug 27 11:26:25 2015 -0700
Committer: Pengcheng Xiong <px...@apache.org>
Committed: Thu Aug 27 11:26:46 2015 -0700
----------------------------------------------------------------------
.../calcite/translator/HiveOpConverter.java | 31 ++++++++++++++++----
1 file changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/9e85bbf2/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
index 4db9863..1931880 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
@@ -686,13 +686,34 @@ public class HiveOpConverter {
int numReducers, Operation acidOperation, boolean strictMode,
List<String> keepColNames) throws SemanticException {
// 1. Generate RS operator
- if (input.getSchema().getTableNames().size() != 1) {
+ // 1.1 Prune the tableNames, only count the tableNames that are not empty strings
+ // as empty string in table aliases is only allowed for virtual columns.
+ String tableAlias = null;
+ Set<String> tableNames = input.getSchema().getTableNames();
+ for (String tableName : tableNames) {
+ if (tableName != null) {
+ if (tableName.length() == 0) {
+ if (tableAlias == null) {
+ tableAlias = tableName;
+ }
+ } else {
+ if (tableAlias == null || tableAlias.length() == 0) {
+ tableAlias = tableName;
+ } else {
+ if (!tableName.equals(tableAlias)) {
+ throw new SemanticException(
+ "In CBO return path, genReduceSinkAndBacktrackSelect is expecting only one tableAlias but there is more than one");
+ }
+ }
+ }
+ }
+ }
+ if (tableAlias == null) {
throw new SemanticException(
- "In CBO return path, genReduceSinkAndBacktrackSelect is expecting only one SelectOp but there is "
- + input.getSchema().getTableNames().size());
+ "In CBO return path, genReduceSinkAndBacktrackSelect is expecting only one tableAlias but there is none");
}
- ReduceSinkOperator rsOp = genReduceSink(input, input.getSchema().getTableNames().iterator()
- .next(), keys, tag, partitionCols, order, numReducers, acidOperation, strictMode);
+ // 1.2 Now generate RS operator
+ ReduceSinkOperator rsOp = genReduceSink(input, tableAlias, keys, tag, partitionCols, order, numReducers, acidOperation, strictMode);
// 2. Generate backtrack Select operator
Map<String, ExprNodeDesc> descriptors = buildBacktrackFromReduceSink(keepColNames,