You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ra...@apache.org on 2016/10/28 12:52:12 UTC
phoenix git commit: PHOENIX-3374 Wrong data row key is getting
generated for local indexes for functions with fixed non null
columns(Rajeshbabu)
Repository: phoenix
Updated Branches:
refs/heads/master 44c5a0328 -> 10880a37c
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/10880a37
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/10880a37
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/10880a37
Branch: refs/heads/master
Commit: 10880a37ca8d9594a6c2bfa5d77639368612fae7
Parents: 44c5a03
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Fri Oct 28 18:32:02 2016 +0530
Committer: Rajeshbabu Chintaguntla <ra...@apache.org>
Committed: Fri Oct 28 18:32:02 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/10880a37/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/10880a37/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();