Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;

import java.util.Objects;
import org.apache.calcite.plan.RelMultipleTrait;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelTrait;
Expand Down Expand Up @@ -95,9 +96,11 @@ public RelDistribution apply(TargetMapping mapping) {
tmp.put(aMapping.source, aMapping.target);
}

for (Integer key : keys) {
newKeys.add(tmp.get(key));
}
keys.stream()
.map(tmp::get)
.filter(Objects::nonNull)
.forEach(newKeys::add);

return new HiveRelDistribution(type, newKeys);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE test (col1 string, col2 string);

EXPLAIN CBO
SELECT col1 FROM test
WHERE col2 = 'a'
DISTRIBUTE BY col1, col2
SORT BY col1, col2;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
PREHOOK: query: CREATE TABLE test (col1 string, col2 string)
PREHOOK: type: CREATETABLE
PREHOOK: Output: database:default
PREHOOK: Output: default@test
POSTHOOK: query: CREATE TABLE test (col1 string, col2 string)
POSTHOOK: type: CREATETABLE
POSTHOOK: Output: database:default
POSTHOOK: Output: default@test
PREHOOK: query: EXPLAIN CBO
SELECT col1 FROM test
WHERE col2 = 'a'
DISTRIBUTE BY col1, col2
SORT BY col1, col2
PREHOOK: type: QUERY
PREHOOK: Input: default@test
#### A masked pattern was here ####
POSTHOOK: query: EXPLAIN CBO
SELECT col1 FROM test
WHERE col2 = 'a'
DISTRIBUTE BY col1, col2
SORT BY col1, col2
POSTHOOK: type: QUERY
POSTHOOK: Input: default@test
#### A masked pattern was here ####
CBO PLAN:
HiveSortExchange(distribution=[hash[0]], collation=[[0]])
HiveProject(col1=[$0])
HiveFilter(condition=[=($1, _UTF-16LE'a')])
HiveTableScan(table=[[default, test]], table:alias=[test])