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 2016/11/04 22:13:43 UTC

[16/50] [abbrv] phoenix git commit: PHOENIX-3374 Wrong data row key is getting generated for local indexes for functions with fixed non null columns(Rajeshbabu)

PHOENIX-3374 Wrong data row key is getting generated for local indexes for functions with fixed non null columns(Rajeshbabu)


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

Branch: refs/heads/encodecolumns2
Commit: 16e4a181c665f1be63a89263d33731e2e18ce8df
Parents: 87266ef
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Fri Oct 28 18:34:05 2016 +0530
Committer: Rajeshbabu Chintaguntla <ra...@apache.org>
Committed: Fri Oct 28 18:34:05 2016 +0530

----------------------------------------------------------------------
 .../phoenix/end2end/index/LocalIndexIT.java     | 21 ++++++++++++++++++++
 .../apache/phoenix/index/IndexMaintainer.java   |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/16e4a181/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
index bf99db0..4ef98a3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
@@ -77,6 +77,27 @@ public class LocalIndexIT extends BaseLocalIndexIT {
         PTable localIndex = conn1.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, indexTableName));
         assertEquals(IndexType.LOCAL, localIndex.getIndexType());
         assertNotNull(localIndex.getViewIndexId());
+        String tableName2 = "test_table" + generateUniqueName();
+        String indexName2 = "idx_test_table" + generateUniqueName();
+        String createTable =
+                "CREATE TABLE IF NOT EXISTS "
+                        + tableName2
+                        + " (user_time UNSIGNED_TIMESTAMP NOT NULL,user_id varchar NOT NULL,col1 varchar,col2 double,"
+                        + "CONSTRAINT pk PRIMARY KEY(user_time,user_id)) SALT_BUCKETS = 20";
+        conn1.createStatement().execute(createTable);
+        conn1.createStatement().execute(
+            "CREATE local INDEX IF NOT EXISTS " + indexName2 + " on " + tableName2
+                    + "(HOUR(user_time))");
+        conn1.createStatement().execute(
+            "upsert into " + tableName2 + " values(TO_TIME('2005-10-01 14:03:22.559'), 'foo')");
+        conn1.commit();
+        ResultSet rs =
+                conn1.createStatement()
+                        .executeQuery(
+                            "select substr(to_char(user_time), 0, 10) as ddate, hour(user_time) as hhour, user_id, col1,col2 from "
+                                    + tableName2
+                                    + " where hour(user_time)=14 group by user_id, col1, col2, ddate, hhour limit 1");
+        assertTrue(rs.next());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/phoenix/blob/16e4a181/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
index 6595562..237ed75 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
@@ -785,7 +785,7 @@ public class IndexMaintainer implements Writable, Iterable<ColumnReference> {
             Integer scaleToBe;
             if (indexField == null) {
                 Expression e = expressionItr.next();
-                isNullableToBe = true;
+                isNullableToBe = e.isNullable();
                 dataTypeToBe = IndexUtil.getIndexColumnDataType(isNullableToBe, e.getDataType());
                 sortOrderToBe = descIndexColumnBitSet.get(i) ? SortOrder.DESC : SortOrder.ASC;
                 maxLengthToBe = e.getMaxLength();