phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajeshb...@apache.org
Subject phoenix git commit: PHOENIX-2313 TypeMismatchException thrown while querying a table that has an index with a Boolean(Rajeshbabu)
Date Sun, 18 Oct 2015 04:22:45 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 177b1b70d -> ad0fd92bb


PHOENIX-2313 TypeMismatchException thrown while querying a table that has an index with a
Boolean(Rajeshbabu)


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

Branch: refs/heads/4.x-HBase-0.98
Commit: ad0fd92bbd5b935ed8d781e3149fc8ea902a33f4
Parents: 177b1b7
Author: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Authored: Sun Oct 18 09:52:23 2015 +0530
Committer: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Committed: Sun Oct 18 09:52:23 2015 +0530

----------------------------------------------------------------------
 .../phoenix/end2end/index/BaseMutableIndexIT.java  | 17 +++++++++++++++++
 .../org/apache/phoenix/schema/types/PBoolean.java  |  4 ++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad0fd92b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseMutableIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseMutableIndexIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseMutableIndexIT.java
index b2f8630..68998cf 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseMutableIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseMutableIndexIT.java
@@ -110,6 +110,23 @@ public abstract class BaseMutableIndexIT extends BaseHBaseManagedTimeIT
{
     }
 
     @Test
+    public void testIndexWithBooleanCol() throws Exception {
+        Connection conn1 = DriverManager.getConnection(getUrl());
+        conn1.createStatement().execute(
+            "create table t( a integer primary key, b boolean, c varchar)");
+        conn1.createStatement().execute(
+            "create " + (localIndex ? "LOCAL" : "") + " index i on t(b)");
+        conn1.createStatement().execute("upsert into t values(1,true,'foo')");
+        conn1.createStatement().execute("upsert into t values(2,false,'foo')");
+        conn1.commit();
+        ResultSet rs = conn1.createStatement().executeQuery("select b from t");
+        rs.next();
+        assertEquals(true, rs.getBoolean(1));
+        rs.next();
+        assertEquals(false, rs.getBoolean(1));
+    }
+
+    @Test
     public void testIndexWithNullableFixedWithCols() throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad0fd92b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBoolean.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBoolean.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBoolean.java
index 66991c5..9892426 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBoolean.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBoolean.java
@@ -17,6 +17,7 @@
  */
 package org.apache.phoenix.schema.types;
 
+import java.math.BigDecimal;
 import java.sql.Types;
 
 import org.apache.phoenix.schema.SortOrder;
@@ -131,6 +132,9 @@ public class PBoolean extends PDataType<Boolean> {
       byte[] bytes = (byte[]) object;
       return toObject(bytes, 0, bytes.length);
     }
+        if (actualType == PDecimal.INSTANCE) {
+            return ((BigDecimal) object).equals(BigDecimal.ONE) ? Boolean.TRUE : Boolean.FALSE;
+        }
     return throwConstraintViolationException(actualType, this);
   }
 


Mime
View raw message