You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2016/05/05 14:45:11 UTC
phoenix git commit: PHOENIX-2878 CURRENT_TIME fails to provide
correct time when projected table is using
Repository: phoenix
Updated Branches:
refs/heads/master 32cf841c4 -> 596726089
PHOENIX-2878 CURRENT_TIME fails to provide correct time when projected table is using
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/59672608
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/59672608
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/59672608
Branch: refs/heads/master
Commit: 596726089a530e261aee27b7680466942a0d1b4c
Parents: 32cf841
Author: maryannxue <ma...@gmail.com>
Authored: Thu May 5 10:45:02 2016 -0400
Committer: maryannxue <ma...@gmail.com>
Committed: Thu May 5 10:45:02 2016 -0400
----------------------------------------------------------------------
.../org/apache/phoenix/end2end/DateTimeIT.java | 17 +++++++++++++++++
.../apache/phoenix/compile/StatementContext.java | 5 ++++-
2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/59672608/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
index 7e407bc..461816a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
@@ -715,4 +715,21 @@ public class DateTimeIT extends BaseHBaseManagedTimeIT {
assertEquals(111111113, rs.getTimestamp(2).getNanos());
assertFalse(rs.next());
}
+
+ @Test
+ public void testCurrentTimeWithProjectedTable () throws Exception {
+ String ddl = "CREATE TABLE T1 ( ID integer primary key)";
+ conn.createStatement().execute(ddl);
+ ddl = "CREATE TABLE T2 ( ID integer primary key)";
+ conn.createStatement().execute(ddl);
+ String ups = "UPSERT INTO T1 VALUES (1)";
+ conn.createStatement().execute(ups);
+ ups = "UPSERT INTO T2 VALUES (1)";
+ conn.createStatement().execute(ups);
+ conn.commit();
+ ResultSet rs = conn.createStatement().executeQuery("select /*+ USE_SORT_MERGE_JOIN */ op" +
+ ".id, current_time() from t1 op where op.id in (select id from t2)");
+ assertTrue(rs.next());
+ assertEquals(new java.util.Date().getYear(),rs.getTimestamp(2).getYear());
+ }
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/59672608/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
index 9f4562a..8ced589 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
@@ -39,6 +39,7 @@ import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.schema.MetaDataClient;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.util.DateUtil;
import org.apache.phoenix.util.NumberUtil;
@@ -253,7 +254,9 @@ public class StatementContext {
public long getCurrentTime() throws SQLException {
long ts = this.getCurrentTable().getTimeStamp();
// if the table is transactional then it is only resolved once per query, so we can't use the table timestamp
- if (!this.getCurrentTable().getTable().isTransactional() && ts != QueryConstants.UNSET_TIMESTAMP) {
+ if (this.getCurrentTable().getTable().getType() != PTableType.PROJECTED && !this
+ .getCurrentTable().getTable().isTransactional() && ts != QueryConstants
+ .UNSET_TIMESTAMP) {
return ts;
}
if (currentTime != QueryConstants.UNSET_TIMESTAMP) {