You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2015/04/16 21:33:52 UTC
[1/2] phoenix git commit: PHOENIX-1861 Padding character should be
inverted if sort order is descending (Dumindu Buddhika)
Repository: phoenix
Updated Branches:
refs/heads/4.3 6f754df66 -> 06e0d6102
PHOENIX-1861 Padding character should be inverted if sort order is
descending (Dumindu Buddhika)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/759b82be
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/759b82be
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/759b82be
Branch: refs/heads/4.3
Commit: 759b82be0afc20d0525e25023cf4fdd12d36191c
Parents: 6f754df
Author: ramkrishna <ra...@gmail.com>
Authored: Tue Apr 14 23:23:49 2015 +0530
Committer: James Taylor <jt...@salesforce.com>
Committed: Thu Apr 16 12:31:47 2015 -0700
----------------------------------------------------------------------
.../src/main/java/org/apache/phoenix/compile/WhereOptimizer.java | 2 +-
.../src/main/java/org/apache/phoenix/schema/PTableImpl.java | 2 +-
.../src/main/java/org/apache/phoenix/schema/types/PBinary.java | 2 +-
.../src/main/java/org/apache/phoenix/schema/types/PChar.java | 4 ++--
.../src/main/java/org/apache/phoenix/schema/types/PDataType.java | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/759b82be/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
index b03793d..a5aef02 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
@@ -1210,7 +1210,7 @@ public class WhereOptimizer {
Integer length = getColumn().getMaxLength();
if (length != null) {
// Go through type to pad as the fill character depends on the type.
- type.pad(ptr, length);
+ type.pad(ptr, length, getColumn().getSortOrder());
}
}
byte[] key = ByteUtil.copyKeyBytesIfNecessary(ptr);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/759b82be/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
index 8ce4183..088595b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
@@ -703,7 +703,7 @@ public class PTableImpl implements PTable {
Integer maxLength = column.getMaxLength();
if (!isNull && type.isFixedWidth() && maxLength != null) {
if (ptr.getLength() <= maxLength) {
- type.pad(ptr, maxLength);
+ type.pad(ptr, maxLength, column.getSortOrder());
} else if (ptr.getLength() > maxLength) {
throw new DataExceedsCapacityException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + type.toObject(byteValue) + ")");
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/759b82be/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
index 25604a3..d6d07fd 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
@@ -35,7 +35,7 @@ public class PBinary extends PDataType<byte[]> {
}
@Override
- public void pad(ImmutableBytesWritable ptr, Integer maxLength) {
+ public void pad(ImmutableBytesWritable ptr, Integer maxLength, SortOrder sortOrder) {
if (ptr.getLength() >= maxLength) {
return;
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/759b82be/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
index 48d47d3..2effc38 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
@@ -41,13 +41,13 @@ public class PChar extends PDataType<String> {
}
@Override
- public void pad(ImmutableBytesWritable ptr, Integer maxLength) {
+ public void pad(ImmutableBytesWritable ptr, Integer maxLength, SortOrder sortOrder) {
if (ptr.getLength() >= maxLength) {
return;
}
byte[] newBytes = new byte[maxLength];
System.arraycopy(ptr.get(), ptr.getOffset(), newBytes, 0, ptr.getLength());
- Arrays.fill(newBytes, ptr.getLength(), maxLength, StringUtil.SPACE_UTF8);
+ Arrays.fill(newBytes, ptr.getLength(), maxLength, sortOrder == SortOrder.ASC ? StringUtil.SPACE_UTF8 : StringUtil.INVERTED_SPACE_UTF8);
ptr.set(newBytes);
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/759b82be/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
index 8f46a3b..43860eb 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
@@ -1172,7 +1172,7 @@ public abstract class PDataType<T> implements DataType<T>, Comparable<PDataType<
return object;
}
- public void pad(ImmutableBytesWritable ptr, Integer maxLength) {
+ public void pad(ImmutableBytesWritable ptr, Integer maxLength, SortOrder sortOrder) {
}
public static PDataType arrayBaseType(PDataType arrayType) {
[2/2] phoenix git commit: PHOENIX-1876 Check for null function
arguments before evaluating when constant
Posted by ja...@apache.org.
PHOENIX-1876 Check for null function arguments before evaluating when constant
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/06e0d610
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/06e0d610
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/06e0d610
Branch: refs/heads/4.3
Commit: 06e0d6102e369b682a2de453762e4b9997f72885
Parents: 759b82b
Author: James Taylor <jt...@salesforce.com>
Authored: Thu Apr 16 10:01:25 2015 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Thu Apr 16 12:32:25 2015 -0700
----------------------------------------------------------------------
.../java/org/apache/phoenix/end2end/DecodeFunctionIT.java | 9 +++------
.../java/org/apache/phoenix/end2end/EncodeFunctionIT.java | 8 ++------
.../java/org/apache/phoenix/compile/ExpressionCompiler.java | 6 +++---
3 files changed, 8 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/06e0d610/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java
index 68e0add..93205a7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.end2end;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -111,12 +112,8 @@ public class DecodeFunctionIT extends BaseHBaseManagedTimeIT {
conn.createStatement().execute(ddl);
- try {
- conn.createStatement().executeQuery("SELECT * FROM test_table WHERE some_column = DECODE('8', NULL)");
- fail();
- } catch (SQLException e) {
- assertEquals(SQLExceptionCode.ILLEGAL_DATA.getErrorCode(), e.getErrorCode());
- }
+ ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM test_table WHERE some_column = DECODE('8', NULL)");
+ assertFalse(rs.next());
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/06e0d610/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
index 489ebfd..ceafc5b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
@@ -116,12 +116,8 @@ public class EncodeFunctionIT extends BaseHBaseManagedTimeIT {
String ddl = "CREATE TABLE TEST_TABLE ( pk VARCHAR(10) NOT NULL CONSTRAINT PK PRIMARY KEY (pk))";
conn.createStatement().execute(ddl);
- try {
- conn.createStatement().executeQuery("SELECT * FROM TEST_TABLE WHERE pk = ENCODE(1, NULL)");
- fail();
- } catch (SQLException e) {
- assertEquals(SQLExceptionCode.ILLEGAL_DATA.getErrorCode(), e.getErrorCode());
- }
+ ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST_TABLE WHERE pk = ENCODE(1, NULL)");
+ assertFalse(rs.next());
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/06e0d610/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
index 81e4059..f474772 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
@@ -312,9 +312,6 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
children = node.validate(children, context);
Expression expression = node.create(children, context);
ImmutableBytesWritable ptr = context.getTempPtr();
- if (ExpressionUtil.isConstant(expression)) {
- return ExpressionUtil.getConstantExpression(expression, ptr);
- }
BuiltInFunctionInfo info = node.getInfo();
for (int i = 0; i < info.getRequiredArgCount(); i++) {
// Optimization to catch cases where a required argument is null resulting in the function
@@ -327,6 +324,9 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
}
}
+ if (ExpressionUtil.isConstant(expression)) {
+ return ExpressionUtil.getConstantExpression(expression, ptr);
+ }
expression = addExpression(expression);
expression = wrapGroupByExpression(expression);
if (aggregateFunction == node) {