You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sa...@apache.org on 2017/02/16 23:47:28 UTC

[1/2] phoenix git commit: Revert "PHOENIX-3683 Backward compatibility fails for joins"

Repository: phoenix
Updated Branches:
  refs/heads/encodecolumns2 0950819ee -> 1d2e2f51f


Revert "PHOENIX-3683 Backward compatibility fails for joins"

This reverts commit 0950819ee46aa9c33b8705e659110674ea79cd25.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/6b91f18b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6b91f18b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6b91f18b

Branch: refs/heads/encodecolumns2
Commit: 6b91f18bc00ef77b080e23e2c6a6ec307cb255e3
Parents: 0950819
Author: Samarth <sa...@salesforce.com>
Authored: Thu Feb 16 15:45:52 2017 -0800
Committer: Samarth <sa...@salesforce.com>
Committed: Thu Feb 16 15:45:52 2017 -0800

----------------------------------------------------------------------
 .../apache/phoenix/compile/WhereCompiler.java   |  53 ++++++---
 .../coprocessor/HashJoinRegionScanner.java      |   4 +-
 .../apache/phoenix/execute/CorrelatePlan.java   |   2 +-
 .../phoenix/execute/SortMergeJoinPlan.java      |   2 +-
 .../apache/phoenix/execute/TupleProjector.java  |   7 +-
 .../filter/MultiKeyValueComparisonFilter.java   | 114 +------------------
 6 files changed, 49 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b91f18b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
index ab90442..3026514 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
@@ -20,7 +20,6 @@ package org.apache.phoenix.compile;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -52,14 +51,15 @@ import org.apache.phoenix.schema.AmbiguousColumnException;
 import org.apache.phoenix.schema.ColumnNotFoundException;
 import org.apache.phoenix.schema.ColumnRef;
 import org.apache.phoenix.schema.PTable;
-import org.apache.phoenix.schema.PTable.ImmutableStorageScheme;
 import org.apache.phoenix.schema.PTable.IndexType;
+import org.apache.phoenix.schema.PTable.ImmutableStorageScheme;
 import org.apache.phoenix.schema.PTableType;
 import org.apache.phoenix.schema.TableRef;
 import org.apache.phoenix.schema.TypeMismatchException;
 import org.apache.phoenix.schema.types.PBoolean;
 import org.apache.phoenix.util.ByteUtil;
 import org.apache.phoenix.util.ExpressionUtil;
+import org.apache.phoenix.util.EncodedColumnsUtil;
 import org.apache.phoenix.util.ScanUtil;
 import org.apache.phoenix.util.SchemaUtil;
 
@@ -210,13 +210,27 @@ public class WhereCompiler {
     }
 
     private static final class Counter {
-        private Set<KeyValueColumnExpression> columns = new HashSet<>();
-        public void addColumn(KeyValueColumnExpression column) {
-            columns.add(column);
+        public enum Count {NONE, SINGLE, MULTIPLE};
+        private Count count = Count.NONE;
+        private KeyValueColumnExpression column;
+
+        public void increment(KeyValueColumnExpression column) {
+            switch (count) {
+                case NONE:
+                    count = Count.SINGLE;
+                    this.column = column;
+                    break;
+                case SINGLE:
+                    count = column.equals(this.column) ? Count.SINGLE : Count.MULTIPLE;
+                    break;
+                case MULTIPLE:
+                    break;
+
+            }
         }
         
-        public int getUniqueKeyValueColumnCount() {
-            return columns.size();
+        public Count getCount() {
+            return count;
         }
     }
 
@@ -234,23 +248,36 @@ public class WhereCompiler {
             Filter filter = null;
             final Counter counter = new Counter();
             whereClause.accept(new KeyValueExpressionVisitor() {
+
+                @Override
+                public Iterator<Expression> defaultIterator(Expression node) {
+                    // Stop traversal once we've found multiple KeyValue columns
+                    if (counter.getCount() == Counter.Count.MULTIPLE) {
+                        return Iterators.emptyIterator();
+                    }
+                    return super.defaultIterator(node);
+                }
+
                 @Override
                 public Void visit(KeyValueColumnExpression expression) {
-                    counter.addColumn(expression);
+                    counter.increment(expression);
                     return null;
                 }
             });
-            int uniqueKeyValueExpressionsCount = counter.getUniqueKeyValueColumnCount();
-            if (uniqueKeyValueExpressionsCount == 0) {
+            switch (counter.getCount()) {
+            case NONE:
                 PTable table = context.getResolver().getTables().get(0).getTable();
                 byte[] essentialCF = table.getType() == PTableType.VIEW 
                         ? ByteUtil.EMPTY_BYTE_ARRAY 
                         : SchemaUtil.getEmptyColumnFamily(table);
                 filter = new RowKeyComparisonFilter(whereClause, essentialCF);
-            } else if (uniqueKeyValueExpressionsCount == 1) {
+                break;
+            case SINGLE:
                 filter = disambiguateWithFamily ? new SingleCFCQKeyValueComparisonFilter(whereClause) : new SingleCQKeyValueComparisonFilter(whereClause);
-            } else {
-                filter = disambiguateWithFamily ? new MultiCFCQKeyValueComparisonFilter(whereClause, counter.getUniqueKeyValueColumnCount()) : new MultiCQKeyValueComparisonFilter(whereClause, counter.getUniqueKeyValueColumnCount());
+                break;
+            case MULTIPLE:
+                filter = disambiguateWithFamily ? new MultiCFCQKeyValueComparisonFilter(whereClause) : new MultiCQKeyValueComparisonFilter(whereClause);
+                break;
             }
             scan.setFilter(filter);
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b91f18b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
index 3044ab0..59ce33c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
@@ -178,7 +178,7 @@ public class HashJoinRegionScanner implements RegionScanner {
                                     lhs : TupleProjector.mergeProjectedValue(
                                             (ProjectedValueTuple) lhs, schema, tempDestBitSet,
                                             null, joinInfo.getSchemas()[i], tempSrcBitSet[i], 
-                                            joinInfo.getFieldPositions()[i], useNewValueColumnQualifier);
+                                            joinInfo.getFieldPositions()[i]);
                             resultQueue.offer(joined);
                             continue;
                         }
@@ -187,7 +187,7 @@ public class HashJoinRegionScanner implements RegionScanner {
                                     lhs : TupleProjector.mergeProjectedValue(
                                             (ProjectedValueTuple) lhs, schema, tempDestBitSet,
                                             t, joinInfo.getSchemas()[i], tempSrcBitSet[i], 
-                                            joinInfo.getFieldPositions()[i], useNewValueColumnQualifier);
+                                            joinInfo.getFieldPositions()[i]);
                             resultQueue.offer(joined);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b91f18b/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
index ee81c36..b1d00ab 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
@@ -159,7 +159,7 @@ public class CorrelatePlan extends DelegateQueryPlan {
                     joined = rhsBitSet == ValueBitSet.EMPTY_VALUE_BITSET ?
                             current : TupleProjector.mergeProjectedValue(
                                     convertLhs(current), joinedSchema, destBitSet,
-                                    rhsCurrent, rhsSchema, rhsBitSet, rhsFieldPosition, true);
+                                    rhsCurrent, rhsSchema, rhsBitSet, rhsFieldPosition);
                 } catch (IOException e) {
                     throw new SQLException(e);
                 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b91f18b/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
index 8913f3b..f4ff289 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
@@ -414,7 +414,7 @@ public class SortMergeJoinPlan implements QueryPlan {
                 return rhsBitSet == ValueBitSet.EMPTY_VALUE_BITSET ?
                         t : TupleProjector.mergeProjectedValue(
                                 t, joinedSchema, destBitSet,
-                                rhs, rhsSchema, rhsBitSet, rhsFieldPosition, true);
+                                rhs, rhsSchema, rhsBitSet, rhsFieldPosition);
             } catch (IOException e) {
                 throw new SQLException(e);
             }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b91f18b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
index 2126026..6a1473c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
@@ -243,7 +243,7 @@ public class TupleProjector {
         }
     }
     
-    public static class OldProjectedValueTuple extends ProjectedValueTuple {
+    public class OldProjectedValueTuple extends ProjectedValueTuple {
 
         public OldProjectedValueTuple(byte[] keyBuffer, int keyOffset, int keyLength, long timestamp,
                 byte[] projectedValue, int valueOffset, int valueLength, int bitSetLen) {
@@ -299,7 +299,7 @@ public class TupleProjector {
     }
     
     public static ProjectedValueTuple mergeProjectedValue(ProjectedValueTuple dest, KeyValueSchema destSchema, ValueBitSet destBitSet,
-    		Tuple src, KeyValueSchema srcSchema, ValueBitSet srcBitSet, int offset, boolean useNewValueColumnQualifier) throws IOException {
+    		Tuple src, KeyValueSchema srcSchema, ValueBitSet srcBitSet, int offset) throws IOException {
     	ImmutableBytesWritable destValue = dest.getProjectedValue();
         int origDestBitSetLen = dest.getBitSetLength();
     	destBitSet.clear();
@@ -326,8 +326,7 @@ public class TupleProjector {
     	    o = Bytes.putBytes(merged, o, srcValue.get(), srcValue.getOffset(), srcValueLen);
     	}
     	destBitSet.toBytes(merged, o);
-        return useNewValueColumnQualifier ? new ProjectedValueTuple(dest, dest.getTimestamp(), merged, 0, merged.length, destBitSetLen) : 
-            new OldProjectedValueTuple(dest, dest.getTimestamp(), merged, 0, merged.length, destBitSetLen);
+        return new ProjectedValueTuple(dest, dest.getTimestamp(), merged, 0, merged.length, destBitSetLen);
     }
 
     public KeyValueSchema getSchema() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b91f18b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java
index 5823e00..88f707d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/MultiKeyValueComparisonFilter.java
@@ -26,11 +26,11 @@ import java.util.TreeSet;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.expression.SingleCellColumnExpression;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.KeyValueColumnExpression;
 import org.apache.phoenix.expression.visitor.ExpressionVisitor;
 import org.apache.phoenix.expression.visitor.StatelessTraverseAllExpressionVisitor;
-import org.apache.phoenix.schema.PTable.QualifierEncodingScheme;
 import org.apache.phoenix.schema.tuple.BaseTuple;
 
 
@@ -47,14 +47,12 @@ public abstract class MultiKeyValueComparisonFilter extends BooleanExpressionFil
     private Boolean matchedColumn;
     protected final IncrementalResultTuple inputTuple = new IncrementalResultTuple();
     protected TreeSet<byte[]> cfSet;
-    protected QualifierEncodingScheme encodingScheme;
 
     public MultiKeyValueComparisonFilter() {
     }
 
-    public MultiKeyValueComparisonFilter(Expression expression, QualifierEncodingScheme encodingScheme) {
+    public MultiKeyValueComparisonFilter(Expression expression) {
         super(expression);
-        this.encodingScheme = encodingScheme;
         init();
     }
 
@@ -182,114 +180,6 @@ public abstract class MultiKeyValueComparisonFilter extends BooleanExpressionFil
         }
     }
     
-    private final class EncodedCQIncrementalResultTuple extends BaseTuple {
-        private int refCount;
-        private final ImmutableBytesWritable keyPtr = new ImmutableBytesWritable(UNITIALIZED_KEY_BUFFER);
-        private final Map<Object,CellRef> foundColumns = new HashMap<Object,CellRef>(5);
-        private final CellRef[] foundColumnsArray = new CellRef[5];
-        
-        public void reset() {
-            refCount = 0;
-            keyPtr.set(UNITIALIZED_KEY_BUFFER);
-            for (CellRef ref : foundColumns.values()) {
-                ref.cell = null;
-            }
-        }
-        
-        @Override
-        public boolean isImmutable() {
-            return refCount == foundColumns.size();
-        }
-        
-        public void setImmutable() {
-            refCount = foundColumns.size();
-        }
-        
-        private ReturnCode resolveColumn(Cell value) {
-            // Always set key, in case we never find a key value column of interest,
-            // and our expression uses row key columns.
-            setKey(value);
-            Object ptr = setColumnKey(value.getFamilyArray(), value.getFamilyOffset(), value.getFamilyLength(), 
-                    value.getQualifierArray(), value.getQualifierOffset(), value.getQualifierLength());
-            CellRef ref = foundColumns.get(ptr);
-            if (ref == null) {
-                // Return INCLUDE_AND_NEXT_COL here. Although this filter doesn't need this KV
-                // it should still be projected into the Result
-                return ReturnCode.INCLUDE_AND_NEXT_COL;
-            }
-            // Since we only look at the latest key value for a given column,
-            // we are not interested in older versions
-            // TODO: test with older versions to confirm this doesn't get tripped
-            // This shouldn't be necessary, because a scan only looks at the latest
-            // version
-            if (ref.cell != null) {
-                // Can't do NEXT_ROW, because then we don't match the other columns
-                // SKIP, INCLUDE, and NEXT_COL seem to all act the same
-                return ReturnCode.NEXT_COL;
-            }
-            ref.cell = value;
-            refCount++;
-            return null;
-        }
-        
-        public void addColumn(byte[] cf, byte[] cq) {
-            Object ptr = MultiKeyValueComparisonFilter.this.newColumnKey(cf, 0, cf.length, cq, 0, cq.length);
-            foundColumns.put(ptr, new CellRef());
-        }
-        
-        public void setKey(Cell value) {
-            keyPtr.set(value.getRowArray(), value.getRowOffset(), value.getRowLength());
-        }
-        
-        @Override
-        public void getKey(ImmutableBytesWritable ptr) {
-            ptr.set(keyPtr.get(),keyPtr.getOffset(),keyPtr.getLength());
-        }
-        
-        @Override
-        public Cell getValue(byte[] cf, byte[] cq) {
-            Object ptr = setColumnKey(cf, 0, cf.length, cq, 0, cq.length);
-            CellRef ref = foundColumns.get(ptr);
-            return ref == null ? null : ref.cell;
-        }
-        
-        @Override
-        public String toString() {
-            return foundColumns.toString();
-        }
-
-        @Override
-        public int size() {
-            return refCount;
-        }
-
-        @Override
-        public Cell getValue(int index) {
-            // This won't perform very well, but it's not
-            // currently used anyway
-            for (CellRef ref : foundColumns.values()) {
-                if (ref.cell == null) {
-                    continue;
-                }
-                if (index == 0) {
-                    return ref.cell;
-                }
-                index--;
-            }
-            throw new IndexOutOfBoundsException(Integer.toString(index));
-        }
-
-        @Override
-        public boolean getValue(byte[] family, byte[] qualifier,
-                ImmutableBytesWritable ptr) {
-            Cell cell = getValue(family, qualifier);
-            if (cell == null)
-                return false;
-            ptr.set(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
-            return true;
-        }
-    }
-     
     protected void init() {
         cfSet = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
         ExpressionVisitor<Void> visitor = new StatelessTraverseAllExpressionVisitor<Void>() {


[2/2] phoenix git commit: PHOENIX-3683 Backward compatibility fails for joins

Posted by sa...@apache.org.
PHOENIX-3683 Backward compatibility fails for joins


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1d2e2f51
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1d2e2f51
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1d2e2f51

Branch: refs/heads/encodecolumns2
Commit: 1d2e2f51fcd8515c313f233086f230262d6e6074
Parents: 6b91f18
Author: Samarth <sa...@salesforce.com>
Authored: Thu Feb 16 15:47:20 2017 -0800
Committer: Samarth <sa...@salesforce.com>
Committed: Thu Feb 16 15:47:20 2017 -0800

----------------------------------------------------------------------
 .../org/apache/phoenix/coprocessor/HashJoinRegionScanner.java | 4 ++--
 .../main/java/org/apache/phoenix/execute/CorrelatePlan.java   | 2 +-
 .../java/org/apache/phoenix/execute/SortMergeJoinPlan.java    | 2 +-
 .../main/java/org/apache/phoenix/execute/TupleProjector.java  | 7 ++++---
 4 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d2e2f51/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
index 59ce33c..3044ab0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java
@@ -178,7 +178,7 @@ public class HashJoinRegionScanner implements RegionScanner {
                                     lhs : TupleProjector.mergeProjectedValue(
                                             (ProjectedValueTuple) lhs, schema, tempDestBitSet,
                                             null, joinInfo.getSchemas()[i], tempSrcBitSet[i], 
-                                            joinInfo.getFieldPositions()[i]);
+                                            joinInfo.getFieldPositions()[i], useNewValueColumnQualifier);
                             resultQueue.offer(joined);
                             continue;
                         }
@@ -187,7 +187,7 @@ public class HashJoinRegionScanner implements RegionScanner {
                                     lhs : TupleProjector.mergeProjectedValue(
                                             (ProjectedValueTuple) lhs, schema, tempDestBitSet,
                                             t, joinInfo.getSchemas()[i], tempSrcBitSet[i], 
-                                            joinInfo.getFieldPositions()[i]);
+                                            joinInfo.getFieldPositions()[i], useNewValueColumnQualifier);
                             resultQueue.offer(joined);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d2e2f51/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
index b1d00ab..ee81c36 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/CorrelatePlan.java
@@ -159,7 +159,7 @@ public class CorrelatePlan extends DelegateQueryPlan {
                     joined = rhsBitSet == ValueBitSet.EMPTY_VALUE_BITSET ?
                             current : TupleProjector.mergeProjectedValue(
                                     convertLhs(current), joinedSchema, destBitSet,
-                                    rhsCurrent, rhsSchema, rhsBitSet, rhsFieldPosition);
+                                    rhsCurrent, rhsSchema, rhsBitSet, rhsFieldPosition, true);
                 } catch (IOException e) {
                     throw new SQLException(e);
                 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d2e2f51/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
index f4ff289..8913f3b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
@@ -414,7 +414,7 @@ public class SortMergeJoinPlan implements QueryPlan {
                 return rhsBitSet == ValueBitSet.EMPTY_VALUE_BITSET ?
                         t : TupleProjector.mergeProjectedValue(
                                 t, joinedSchema, destBitSet,
-                                rhs, rhsSchema, rhsBitSet, rhsFieldPosition);
+                                rhs, rhsSchema, rhsBitSet, rhsFieldPosition, true);
             } catch (IOException e) {
                 throw new SQLException(e);
             }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d2e2f51/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
index 6a1473c..2126026 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java
@@ -243,7 +243,7 @@ public class TupleProjector {
         }
     }
     
-    public class OldProjectedValueTuple extends ProjectedValueTuple {
+    public static class OldProjectedValueTuple extends ProjectedValueTuple {
 
         public OldProjectedValueTuple(byte[] keyBuffer, int keyOffset, int keyLength, long timestamp,
                 byte[] projectedValue, int valueOffset, int valueLength, int bitSetLen) {
@@ -299,7 +299,7 @@ public class TupleProjector {
     }
     
     public static ProjectedValueTuple mergeProjectedValue(ProjectedValueTuple dest, KeyValueSchema destSchema, ValueBitSet destBitSet,
-    		Tuple src, KeyValueSchema srcSchema, ValueBitSet srcBitSet, int offset) throws IOException {
+    		Tuple src, KeyValueSchema srcSchema, ValueBitSet srcBitSet, int offset, boolean useNewValueColumnQualifier) throws IOException {
     	ImmutableBytesWritable destValue = dest.getProjectedValue();
         int origDestBitSetLen = dest.getBitSetLength();
     	destBitSet.clear();
@@ -326,7 +326,8 @@ public class TupleProjector {
     	    o = Bytes.putBytes(merged, o, srcValue.get(), srcValue.getOffset(), srcValueLen);
     	}
     	destBitSet.toBytes(merged, o);
-        return new ProjectedValueTuple(dest, dest.getTimestamp(), merged, 0, merged.length, destBitSetLen);
+        return useNewValueColumnQualifier ? new ProjectedValueTuple(dest, dest.getTimestamp(), merged, 0, merged.length, destBitSetLen) : 
+            new OldProjectedValueTuple(dest, dest.getTimestamp(), merged, 0, merged.length, destBitSetLen);
     }
 
     public KeyValueSchema getSchema() {