Repository: phoenix Updated Branches: refs/heads/master 4eed109b4 -> 10109d55d
PHOENIX-4611 Not nullable column impact on join query plans Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/10109d55 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/10109d55 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/10109d55 Branch: refs/heads/master Commit: 10109d55d4e8d4c69da53fb02e6c9b98d7721ea1 Parents: 4eed109 Author: maryannxue <maryann....@gmail.com> Authored: Fri Feb 16 21:03:46 2018 -0800 Committer: maryannxue <maryann....@gmail.com> Committed: Fri Feb 16 21:03:46 2018 -0800 ---------------------------------------------------------------------- .../java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java | 8 ++++---- .../java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java | 4 ++-- .../main/java/org/apache/phoenix/compile/JoinCompiler.java | 4 ++++ .../org/apache/phoenix/compile/TupleProjectionCompiler.java | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/10109d55/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java index a132728..dea349a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java @@ -440,8 +440,8 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { " SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + " CLIENT MERGE SORT\n" + " CLIENT SORTED BY [BUCKET, \"TIMESTAMP\"]\n" + - "CLIENT SORTED BY [E.BUCKET, E.TIMESTAMP]\n" + - "CLIENT AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, E.TIMESTAMP]" + "CLIENT SORTED BY [E.TIMESTAMP, E.BUCKET]\n" + + "CLIENT AGGREGATE INTO DISTINCT ROWS BY [E.TIMESTAMP, E.BUCKET]" : "SORT-MERGE-JOIN (INNER) TABLES\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + eventCountTableName + " [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + @@ -456,8 +456,8 @@ public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { " SERVER DISTINCT PREFIX FILTER OVER [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + " SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY [BUCKET, \"TIMESTAMP\", SRC_LOCATION, DST_LOCATION]\n" + " CLIENT MERGE SORT\n" + - "CLIENT SORTED BY [E.BUCKET, E.TIMESTAMP]\n" + - "CLIENT AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, E.TIMESTAMP]"; + "CLIENT SORTED BY [E.TIMESTAMP, E.BUCKET]\n" + + "CLIENT AGGREGATE INTO DISTINCT ROWS BY [E.TIMESTAMP, E.BUCKET]"; ResultSet rs = conn.createStatement().executeQuery("explain " + q); assertEquals(p, QueryUtil.getExplainPlan(rs)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/10109d55/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java index f09f1d3..3a1b015 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinMoreIT.java @@ -786,7 +786,7 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { String p = i == 0 ? "CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER EVENT_COUNT [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + " SERVER FILTER BY FIRST KEY ONLY\n" + - " SERVER AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, \"E.TIMESTAMP\"]\n" + + " SERVER AGGREGATE INTO DISTINCT ROWS BY [\"E.TIMESTAMP\", E.BUCKET]\n" + "CLIENT MERGE SORT\n" + " PARALLEL INNER-JOIN TABLE 0 (SKIP MERGE)\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + t[i] + " [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + @@ -795,7 +795,7 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { : "CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER EVENT_COUNT [0,'5SEC',~1462993520000000000,'Tr/Bal'] - [1,'5SEC',~1462993420000000000,'Tr/Bal']\n" + " SERVER FILTER BY FIRST KEY ONLY\n" + - " SERVER AGGREGATE INTO DISTINCT ROWS BY [E.BUCKET, \"E.TIMESTAMP\"]\n" + + " SERVER AGGREGATE INTO DISTINCT ROWS BY [\"E.TIMESTAMP\", E.BUCKET]\n" + "CLIENT MERGE SORT\n" + " PARALLEL INNER-JOIN TABLE 0 (SKIP MERGE)\n" + " CLIENT PARALLEL 2-WAY SKIP SCAN ON 2 RANGES OVER " + t[i] + " [0,'5SEC',1462993420000000001,'Tr/Bal'] - [1,'5SEC',1462993520000000000,'Tr/Bal']\n" + http://git-wip-us.apache.org/repos/asf/phoenix/blob/10109d55/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java index 4020cf9..cf5a5dc 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java @@ -561,6 +561,10 @@ public class JoinCompiler { } compiled.add(new Pair<Expression, Expression>(left, right)); } + // TODO PHOENIX-4618: + // For Stategy.SORT_MERGE, we probably need to re-order the join keys based on the + // specific ordering required by the join's parent, or re-order the following way + // to align with group-by expressions' re-ordering. if (strategy != Strategy.SORT_MERGE) { Collections.sort(compiled, new Comparator<Pair<Expression, Expression>>() { @Override http://git-wip-us.apache.org/repos/asf/phoenix/blob/10109d55/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java index fccded2..6e52cd5 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java @@ -185,7 +185,7 @@ public class TupleProjectionCompiler { PName familyName = SchemaUtil.isPKColumn(sourceColumn) ? (retainPKColumns ? null : PNameFactory.newName(VALUE_COLUMN_FAMILY)) : sourceColumn.getFamilyName(); // If we're not retaining the PK columns, then we should switch columns to be nullable PColumn column = new ProjectedColumn(PNameFactory.newName(aliasedName), familyName, - position++, sourceColumn.isNullable() || familyName != null, sourceColumnRef, sourceColumn.getColumnQualifierBytes()); + position++, sourceColumn.isNullable(), sourceColumnRef, sourceColumn.getColumnQualifierBytes()); projectedColumns.add(column); } EncodedCQCounter cqCounter = EncodedCQCounter.NULL_COUNTER;