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 2017/09/06 02:27:06 UTC
[1/2] phoenix git commit: PHOENIX-4151 Tests extending BaseQueryIT
are flapping
Repository: phoenix
Updated Branches:
refs/heads/master a1c75a9ec -> a3bb174bc
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java
index f72caf9..c5283cd 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryIT.java
@@ -50,7 +50,6 @@ import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.schema.types.PTimestamp;
-import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.PropertiesUtil;
import org.junit.Test;
@@ -76,25 +75,16 @@ public class QueryIT extends BaseQueryIT {
" A_INTEGER) " +
"VALUES (?, ?, ?)";
// Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- Connection upsertConn = DriverManager.getConnection(url, props);
- upsertConn.setAutoCommit(true); // Test auto commit
- PreparedStatement stmt = upsertConn.prepareStatement(updateStmt);
+ Connection conn = DriverManager.getConnection(url, props);
+ PreparedStatement stmt = conn.prepareStatement(updateStmt);
stmt.setString(1, tenantId);
stmt.setString(2, ROW4);
stmt.setInt(3, -10);
stmt.execute();
- upsertConn.close();
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 6);
- props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- upsertConn = DriverManager.getConnection(url, props);
- analyzeTable(upsertConn, tableName);
- upsertConn.close();
-
+ conn.commit();
+
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and a_integer >= ?";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
- Connection conn = DriverManager.getConnection(getUrl(), props);
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
statement.setInt(2, 7);
@@ -127,7 +117,6 @@ public class QueryIT extends BaseQueryIT {
public void testToDateOnString() throws Exception { // TODO: test more conversion combinations
String query = "SELECT a_string FROM " + tableName + " WHERE organization_id=? and a_integer = 5";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -143,12 +132,10 @@ public class QueryIT extends BaseQueryIT {
}
}
-
@Test
public void testColumnOnBothSides() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and a_string = b_string";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -165,7 +152,6 @@ public class QueryIT extends BaseQueryIT {
@Test
public void testDateInList() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE a_date IN (?,?) AND a_integer < 4";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -191,7 +177,6 @@ public class QueryIT extends BaseQueryIT {
" A_TIMESTAMP) " +
"VALUES (?, ?, ?)";
// Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 10);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
@@ -203,7 +188,6 @@ public class QueryIT extends BaseQueryIT {
stmt.setTimestamp(3, tsValue1);
stmt.execute();
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 15);
Connection conn1 = DriverManager.getConnection(url, props);
analyzeTable(conn1, tableName);
conn1.close();
@@ -231,8 +215,7 @@ public class QueryIT extends BaseQueryIT {
assertFalse(compare(CompareOp.GREATER, new ImmutableBytesWritable(ts1), new ImmutableBytesWritable(ts1)));
String query = "SELECT entity_id, a_timestamp, a_time FROM " + tableName + " WHERE organization_id=? and a_timestamp > ?";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); // Execute at timestamp 2
- Connection conn = DriverManager.getConnection(getUrl(), props);
+ Connection conn = DriverManager.getConnection(url, props);
try {
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
@@ -251,7 +234,6 @@ public class QueryIT extends BaseQueryIT {
@Test
public void testSimpleInListStatement() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND a_integer IN (2,4)";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -267,7 +249,6 @@ public class QueryIT extends BaseQueryIT {
@Test
public void testPartiallyQualifiedRVCInList() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE (a_integer,a_string) IN ((2,'a'),(5,'b'))";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -282,7 +263,6 @@ public class QueryIT extends BaseQueryIT {
@Test
public void testFullyQualifiedRVCInList() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE (a_integer,a_string, organization_id,entity_id) IN ((2,'a',:1,:2),(5,'b',:1,:3))";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -300,7 +280,6 @@ public class QueryIT extends BaseQueryIT {
@Test
public void testOneInListStatement() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND b_string IN (?)";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -324,7 +303,6 @@ public class QueryIT extends BaseQueryIT {
@Test
public void testMixedTypeInListStatement() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND x_long IN (5, ?)";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -347,7 +325,6 @@ public class QueryIT extends BaseQueryIT {
public void testIsNull() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE X_DECIMAL is null";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -374,7 +351,6 @@ public class QueryIT extends BaseQueryIT {
public void testIsNotNull() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE X_DECIMAL is not null";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -405,7 +381,6 @@ public class QueryIT extends BaseQueryIT {
for (String query : queries) {
Properties props = new Properties();
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -424,7 +399,6 @@ public class QueryIT extends BaseQueryIT {
public void testRowKeySingleIn() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id IN (?,?,?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -450,7 +424,6 @@ public class QueryIT extends BaseQueryIT {
public void testRowKeyMultiIn() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id IN (?,?,?) and a_string IN (?,?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -475,7 +448,6 @@ public class QueryIT extends BaseQueryIT {
public void testColumnAliasMapping() throws Exception {
String query = "SELECT a.a_string, " + tableName + ".b_string FROM " + tableName + " a WHERE ?=organization_id and 5=a_integer ORDER BY a_string, b_string";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java
index c77c06f..2bde28c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java
@@ -43,7 +43,6 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
-import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.PropertiesUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -70,7 +69,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScan() throws Exception {
String query = "SELECT a_string, /* comment ok? */ b_string FROM " + tableName + " WHERE ?=organization_id and 5=a_integer";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -89,7 +87,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScanByByteValue() throws Exception {
String query = "SELECT a_string, b_string, a_byte FROM " + tableName + " WHERE ?=organization_id and 1=a_byte";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -109,7 +106,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScanByShortValue() throws Exception {
String query = "SELECT a_string, b_string, a_short FROM " + tableName + " WHERE ?=organization_id and 128=a_short";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -129,7 +125,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScanByFloatValue() throws Exception {
String query = "SELECT a_string, b_string, a_float FROM " + tableName + " WHERE ?=organization_id and ?=a_float";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -150,7 +145,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScanByUnsignedFloatValue() throws Exception {
String query = "SELECT a_string, b_string, a_unsigned_float FROM " + tableName + " WHERE ?=organization_id and ?=a_unsigned_float";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -171,7 +165,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScanByDoubleValue() throws Exception {
String query = "SELECT a_string, b_string, a_double FROM " + tableName + " WHERE ?=organization_id and ?=a_double";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -192,7 +185,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testScanByUnsigned_DoubleValue() throws Exception {
String query = "SELECT a_string, b_string, a_unsigned_double FROM " + tableName + " WHERE ?=organization_id and ?=a_unsigned_double";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -213,7 +205,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testAllScan() throws Exception {
String query = "SELECT ALL a_string, b_string FROM " + tableName + " WHERE ?=organization_id and 5=a_integer";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -232,7 +223,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testDistinctScan() throws Exception {
String query = "SELECT DISTINCT a_string FROM " + tableName + " WHERE organization_id=?";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -254,7 +244,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testDistinctLimitScan() throws Exception {
String query = "SELECT DISTINCT a_string FROM " + tableName + " WHERE organization_id=? LIMIT 1";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -272,7 +261,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testInListSkipScan() throws Exception {
String query = "SELECT entity_id, b_string FROM " + tableName + " WHERE organization_id=? and entity_id IN (?,?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -299,7 +287,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testUnboundRangeScan1() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id <= ?";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -333,7 +320,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testUnboundRangeScan2() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id >= ?";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -367,7 +353,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testUpperLowerBoundRangeScan() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and substr(entity_id,1,3) > '00A' and substr(entity_id,1,3) < '00C'";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -391,7 +376,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testUpperBoundRangeScan() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and substr(entity_id,1,3) >= '00B' ";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -417,7 +401,6 @@ public class ScanQueryIT extends BaseQueryIT {
public void testLowerBoundRangeScan() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and substr(entity_id,1,3) < '00B' ";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
index 2a3dd54..10f465f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
@@ -1376,4 +1376,69 @@ public class SequenceIT extends BaseClientManagedTimeIT {
assertFalse(rs.next());
}
+ @Test
+ public void testPointInTimeSequence() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ Connection conn;
+ ResultSet rs;
+ String seqName = generateUniqueName();
+ long ts = nextTimestamp();
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
+ conn = DriverManager.getConnection(getUrl(), props);
+ conn.createStatement().execute("CREATE SEQUENCE " + seqName + "");
+
+ try {
+ conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ fail();
+ } catch (SequenceNotFoundException e) {
+ conn.close();
+ }
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
+ conn = DriverManager.getConnection(getUrl(), props);
+ rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ assertTrue(rs.next());
+ assertEquals(1, rs.getInt(1));
+ conn.close();
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 7));
+ conn = DriverManager.getConnection(getUrl(), props);
+ rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ conn.close();
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 15));
+ conn = DriverManager.getConnection(getUrl(), props);
+ conn.createStatement().execute("DROP SEQUENCE " + seqName + "");
+ rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ assertTrue(rs.next());
+ assertEquals(3, rs.getInt(1));
+ conn.close();
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
+ conn = DriverManager.getConnection(getUrl(), props);
+ try {
+ rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ fail();
+ } catch (SequenceNotFoundException e) { // expected
+ }
+
+ conn.createStatement().execute("CREATE SEQUENCE " + seqName);
+ conn.close();
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 25));
+ conn = DriverManager.getConnection(getUrl(), props);
+ rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ assertTrue(rs.next());
+ assertEquals(1, rs.getInt(1));
+ conn.close();
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 6));
+ conn = DriverManager.getConnection(getUrl(), props);
+ rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+ assertTrue(rs.next());
+ assertEquals(4, rs.getInt(1));
+ conn.close();
+ }
+
}
\ No newline at end of file
[2/2] phoenix git commit: PHOENIX-4151 Tests extending BaseQueryIT
are flapping
Posted by sa...@apache.org.
PHOENIX-4151 Tests extending BaseQueryIT are flapping
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a3bb174b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a3bb174b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a3bb174b
Branch: refs/heads/master
Commit: a3bb174bc82743aa2ac7b59b9d1978a788a4d19f
Parents: a1c75a9
Author: Samarth Jain <sa...@apache.org>
Authored: Tue Sep 5 19:27:01 2017 -0700
Committer: Samarth Jain <sa...@apache.org>
Committed: Tue Sep 5 19:27:01 2017 -0700
----------------------------------------------------------------------
.../phoenix/end2end/AggregateQueryIT.java | 11 +-
.../org/apache/phoenix/end2end/BaseQueryIT.java | 7 +-
.../apache/phoenix/end2end/CaseStatementIT.java | 16 +-
.../apache/phoenix/end2end/CastAndCoerceIT.java | 13 +-
.../end2end/ClientTimeArithmeticQueryIT.java | 35 +--
.../org/apache/phoenix/end2end/GroupByIT.java | 300 +++++++++----------
.../apache/phoenix/end2end/MutableQueryIT.java | 59 ++--
.../org/apache/phoenix/end2end/NotQueryIT.java | 11 -
.../phoenix/end2end/PointInTimeQueryIT.java | 105 -------
.../org/apache/phoenix/end2end/QueryIT.java | 38 +--
.../org/apache/phoenix/end2end/ScanQueryIT.java | 17 --
.../org/apache/phoenix/end2end/SequenceIT.java | 65 ++++
12 files changed, 258 insertions(+), 419 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java
index cec8a1f..01c6e37 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java
@@ -53,7 +53,6 @@ public class AggregateQueryIT extends BaseQueryIT {
public void testGroupByPlusOne() throws Exception {
String query = "SELECT a_integer+1 FROM " + tableName + " WHERE organization_id=? and a_integer = 5 GROUP BY a_integer+1";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -72,7 +71,6 @@ public class AggregateQueryIT extends BaseQueryIT {
// Tests that you don't get an ambiguous column exception when using the same alias as the column name
String query = "SELECT a_string, b_string, count(1) FROM " + tableName + " WHERE organization_id=? and entity_id<=? GROUP BY a_string,b_string";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
HBaseAdmin admin = null;
try {
@@ -99,7 +97,7 @@ public class AggregateQueryIT extends BaseQueryIT {
HTable htable = (HTable) conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(tableNameBytes);
htable.clearRegionCache();
int nRegions = htable.getRegionLocations().size();
- admin.split(tableNameBytes, ByteUtil.concat(Bytes.toBytes(tenantId), Bytes.toBytes("00A" + Character.valueOf((char) ('3' + nextRunCount())) + ts))); // vary split point with test run
+ admin.split(tableNameBytes, ByteUtil.concat(Bytes.toBytes(tenantId), Bytes.toBytes("00A" + Character.valueOf((char) ('3' + nextRunCount()))))); // vary split point with test run
int retryCount = 0;
do {
Thread.sleep(2000);
@@ -135,7 +133,6 @@ public class AggregateQueryIT extends BaseQueryIT {
public void testCountIsNull() throws Exception {
String query = "SELECT count(1) FROM " + tableName + " WHERE X_DECIMAL is null";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -153,8 +150,7 @@ public class AggregateQueryIT extends BaseQueryIT {
public void testCountWithNoScanRanges() throws Exception {
String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id = 'not_existing_organization_id'";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
- Connection conn = DriverManager.getConnection(getUrl(), props);
+ Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
ResultSet rs = statement.executeQuery();
@@ -188,7 +184,6 @@ public class AggregateQueryIT extends BaseQueryIT {
public void testCountIsNotNull() throws Exception {
String query = "SELECT count(1) FROM " + tableName + " WHERE X_DECIMAL is not null";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -207,7 +202,7 @@ public class AggregateQueryIT extends BaseQueryIT {
@Test
public void testInFilterOnKey() throws Exception {
String query = "SELECT count(entity_id) FROM " + tableName + " WHERE organization_id IN (?,?)";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
index ce86278..5477e74 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
@@ -36,7 +36,6 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.schema.PTableImpl;
import org.apache.phoenix.util.ByteUtil;
-import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.junit.BeforeClass;
@@ -89,7 +88,6 @@ public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
}
- protected long ts;
protected Date date;
private String indexDDL;
private String tableDDLOptions;
@@ -118,11 +116,10 @@ public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
optionBuilder.append("KEEP_DELETED_CELLS=true");
}
this.tableDDLOptions = optionBuilder.toString();
- this.ts = nextTimestamp();
try {
this.tableName =
initATableValues(generateUniqueName(), tenantId, getDefaultSplits(tenantId),
- date = new Date(System.currentTimeMillis()), ts, getUrl(), tableDDLOptions);
+ date = new Date(System.currentTimeMillis()), null, getUrl(), tableDDLOptions);
} catch (Exception e) {
logger.error("Exception when creating aTable ", e);
throw e;
@@ -133,8 +130,6 @@ public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
String.format(idxDdl, indexName, tableName,
keepDeletedCells ? "KEEP_DELETED_CELLS=true" : "KEEP_DELETED_CELLS=false");
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
-
try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
conn.createStatement().execute(this.indexDDL);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CaseStatementIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CaseStatementIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CaseStatementIT.java
index 9d6a53e..4e78fdc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CaseStatementIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CaseStatementIT.java
@@ -66,7 +66,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testSimpleCaseStatement() throws Exception {
String query = "SELECT CASE a_integer WHEN 1 THEN 'a' WHEN 2 THEN 'b' WHEN 3 THEN 'c' ELSE 'd' END, entity_id AS a FROM " + tableName + " WHERE organization_id=? AND a_integer < 6";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -89,7 +89,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testMultiCondCaseStatement() throws Exception {
String query = "SELECT CASE WHEN a_integer <= 2 THEN 1.5 WHEN a_integer = 3 THEN 2 WHEN a_integer <= 6 THEN 4.5 ELSE 5 END AS a FROM " + tableName + " WHERE organization_id=?";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -123,7 +123,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testPartialEvalCaseStatement() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and CASE WHEN 1234 = a_integer THEN 1 WHEN x_integer = 5 THEN 2 ELSE 3 END = 2";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -141,7 +141,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testFoundIndexOnPartialEvalCaseStatement() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and CASE WHEN a_integer = 1234 THEN 1 WHEN x_integer = 3 THEN y_integer ELSE 3 END = 300";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -160,7 +160,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testUnfoundMultiColumnCaseStatement() throws Exception {
String query = "SELECT entity_id, b_string FROM " + tableName + " WHERE organization_id=? and CASE WHEN a_integer = 1234 THEN 1 WHEN a_date < ? THEN y_integer WHEN x_integer = 4 THEN 4 ELSE 3 END = 4";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -179,7 +179,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testNonNullMultiCondCaseStatement() throws Exception {
String query = "SELECT CASE WHEN entity_id = '000000000000000' THEN 1 WHEN entity_id = '000000000000001' THEN 2 ELSE 3 END FROM " + tableName + " WHERE organization_id=?";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -196,7 +196,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testNullMultiCondCaseStatement() throws Exception {
String query = "SELECT CASE WHEN entity_id = '000000000000000' THEN 1 WHEN entity_id = '000000000000001' THEN 2 END FROM " + tableName + " WHERE organization_id=?";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -213,7 +213,7 @@ public class CaseStatementIT extends BaseQueryIT {
@Test
public void testNullabilityMultiCondCaseStatement() throws Exception {
String query = "SELECT CASE WHEN a_integer <= 2 THEN ? WHEN a_integer = 3 THEN ? WHEN a_integer <= ? THEN ? ELSE 5 END AS a FROM " + tableName + " WHERE organization_id=?";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CastAndCoerceIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CastAndCoerceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CastAndCoerceIT.java
index d47275d..c4e334a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CastAndCoerceIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CastAndCoerceIT.java
@@ -56,7 +56,6 @@ public class CastAndCoerceIT extends BaseQueryIT {
public void testCastOperatorInSelect() throws Exception {
String query = "SELECT CAST(a_integer AS decimal)/2 FROM " + tableName + " WHERE ?=organization_id and 5=a_integer";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -74,7 +73,6 @@ public class CastAndCoerceIT extends BaseQueryIT {
public void testCastOperatorInWhere() throws Exception {
String query = "SELECT a_integer FROM " + tableName + " WHERE ?=organization_id and 2.5 = CAST(a_integer AS DECIMAL)/2 ";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -91,7 +89,7 @@ public class CastAndCoerceIT extends BaseQueryIT {
@Test
public void testCoerceIntegerToLong() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND x_long >= x_integer";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -111,7 +109,7 @@ public class CastAndCoerceIT extends BaseQueryIT {
@Test
public void testCoerceLongToDecimal1() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND x_decimal > x_integer";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -129,7 +127,7 @@ public class CastAndCoerceIT extends BaseQueryIT {
@Test
public void testCoerceLongToDecimal2() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND x_integer <= x_decimal";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -147,7 +145,7 @@ public class CastAndCoerceIT extends BaseQueryIT {
@Test
public void testCoerceTinyIntToSmallInt() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? AND a_byte >= a_short";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -173,12 +171,11 @@ public class CastAndCoerceIT extends BaseQueryIT {
BigDecimal dateAsDecimal;
String url;
Connection conn;
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3);
+ url = getUrl();
conn = DriverManager.getConnection(url, props);
conn.setAutoCommit(true);
conn.createStatement().execute("UPSERT INTO " + tableName + " (organization_id,entity_id,a_time,a_timestamp) SELECT organization_id,entity_id,a_date,a_date FROM " + tableName);
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5);
conn = DriverManager.getConnection(url, props);
try {
query = "SELECT entity_id, CAST(a_date AS BIGINT) FROM " + tableName + " WHERE organization_id=? AND a_date IS NOT NULL LIMIT 1";
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ClientTimeArithmeticQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ClientTimeArithmeticQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ClientTimeArithmeticQueryIT.java
index 6f76787..52044a8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ClientTimeArithmeticQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ClientTimeArithmeticQueryIT.java
@@ -72,7 +72,7 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
@Test
public void testDateAdd() throws Exception {
String query = "SELECT entity_id, b_string FROM " + tableName + " WHERE a_date + CAST(0.5 AS DOUBLE) < ?";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -94,7 +94,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDecimalAddExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER + X_DECIMAL > 11";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -113,7 +112,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDoubleAddExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where a_double + a_float > 0.08";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -132,7 +130,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testUnsignedDoubleAddExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where a_unsigned_double + a_unsigned_float > 0.08";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -161,7 +158,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
for (String query : queries) {
Properties props = new Properties();
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -177,7 +173,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testIntSubtractionExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER - 4 <= 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -191,7 +186,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDecimalSubtraction1Expression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER - 3.5 <= 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -205,7 +199,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDecimalSubtraction2Expression() throws Exception {// check if decimal part makes a difference
String query = "SELECT entity_id FROM " + tableName + " where X_DECIMAL - 3.5 > 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -221,7 +214,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testLongSubtractionExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where X_LONG - 1 < 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -237,7 +229,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDoubleSubtractionExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where a_double - CAST(0.0002 AS DOUBLE) < 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -253,7 +244,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testSmallIntSubtractionExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where a_short - 129 = 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -270,7 +260,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testTernarySubtractionExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where X_INTEGER - X_LONG - 10 < 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -288,7 +277,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testSelectWithSubtractionExpression() throws Exception {
String query = "SELECT entity_id, x_integer - 4 FROM " + tableName + " where x_integer - 4 = 0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -305,7 +293,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testConstantSubtractionExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER = 5 - 1 - 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -322,7 +309,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testIntDivideExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER / 3 > 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -339,7 +325,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDoubleDivideExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where a_double / CAST(3.0 AS DOUBLE) = 0.0003";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -356,7 +341,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testSmallIntDivideExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where a_short / 135 = 1";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -373,7 +357,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testIntToDecimalDivideExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER / 3.0 > 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -388,7 +371,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testConstantDivideExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER = 9 / 3 / 3";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -404,7 +386,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testSelectWithDivideExpression() throws Exception {
String query = "SELECT entity_id, a_integer/3 FROM " + tableName + " where a_integer = 9";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -422,7 +403,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testNegateExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER - 4 = -1";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -439,7 +419,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testIntMultiplyExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER * 2 = 16";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -456,7 +435,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDoubleMultiplyExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_DOUBLE * CAST(2.0 AS DOUBLE) = 0.0002";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -473,7 +451,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testLongMultiplyExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where X_LONG * 2 * 2 = 20";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -490,7 +467,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testIntToDecimalMultiplyExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER * 1.5 > 9";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -506,7 +482,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testDecimalMultiplyExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where X_DECIMAL * A_INTEGER > 29.5";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -521,7 +496,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testIntAddExpression() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " where A_INTEGER + 2 = 4";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -538,7 +512,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
public void testCoalesceFunction() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE coalesce(X_DECIMAL,0.0) = 0.0";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + tableName + " (organization_id,entity_id,x_decimal) values(?,?,?)");
stmt.setString(1, getOrganizationId());
@@ -559,7 +532,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
stmt.execute();
conn.commit();
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20)); // Execute at timestamp 2
conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -577,7 +549,7 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
@Test
public void testDateSubtract() throws Exception {
String query = "SELECT entity_id, b_string FROM " + tableName + " WHERE a_date - CAST(0.5 AS DOUBLE) > ?";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
try {
@@ -600,7 +572,7 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
String url;
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 15);
+ url = getUrl();
Connection conn = DriverManager.getConnection(url, props);
PreparedStatement statement = conn.prepareStatement("UPSERT INTO " + tableName + " (organization_id,entity_id,a_time) VALUES(?,?,?)");
statement.setString(1, getOrganizationId());
@@ -622,7 +594,6 @@ public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
conn.commit();
conn.close();
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 25);
conn = DriverManager.getConnection(url, props);
try {
statement = conn.prepareStatement("SELECT entity_id, b_string FROM " + tableName + " WHERE a_date - a_time > 1");
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
index b337c00..27aa234 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
@@ -61,7 +61,7 @@ public class GroupByIT extends BaseQueryIT {
public void testNoWhereScan() throws Exception {
String query = "SELECT y_integer FROM " + tableName;
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
+ //props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -88,7 +88,6 @@ public class GroupByIT extends BaseQueryIT {
// Tests that you don't get an ambiguous column exception when using the same alias as the column name
String query = "SELECT a_string as a_string, count(1), 'foo' FROM " + tableName + " WHERE organization_id=? GROUP BY a_string";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -116,7 +115,6 @@ public class GroupByIT extends BaseQueryIT {
public void testDistinctGroupedAggregation() throws Exception {
String query = "SELECT DISTINCT a_string, count(1), 'foo' FROM " + tableName + " WHERE organization_id=? GROUP BY a_string, b_string ORDER BY a_string, count(1)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -158,7 +156,6 @@ public class GroupByIT extends BaseQueryIT {
public void testDistinctLimitedGroupedAggregation() throws Exception {
String query = "SELECT /*+ NO_INDEX */ DISTINCT a_string, count(1), 'foo' FROM " + tableName + " WHERE organization_id=? GROUP BY a_string, b_string ORDER BY count(1) desc,a_string LIMIT 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -196,7 +193,6 @@ public class GroupByIT extends BaseQueryIT {
public void testDistinctUngroupedAggregation() throws Exception {
String query = "SELECT DISTINCT count(1), 'foo' FROM " + tableName + " WHERE organization_id=?";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -215,7 +211,6 @@ public class GroupByIT extends BaseQueryIT {
public void testGroupedLimitedAggregation() throws Exception {
String query = "SELECT a_string, count(1) FROM " + tableName + " WHERE organization_id=? GROUP BY a_string LIMIT 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -234,59 +229,10 @@ public class GroupByIT extends BaseQueryIT {
}
@Test
- public void testPointInTimeGroupedAggregation() throws Exception {
- String updateStmt =
- "upsert into " + tableName +
- " VALUES ('" + tenantId + "','" + ROW5 + "','" + C_VALUE +"')";
- // Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
- Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- Connection upsertConn = DriverManager.getConnection(url, props);
- upsertConn.setAutoCommit(true); // Test auto commit
- // Insert all rows at ts
- Statement stmt = upsertConn.createStatement();
- stmt.execute(updateStmt); // should commit too
- upsertConn.close();
-
- // Override value again, but should be ignored since it's past the SCN
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3); // Run query at timestamp 5
- upsertConn = DriverManager.getConnection(url, props);
- upsertConn.setAutoCommit(true); // Test auto commit
- updateStmt =
- "upsert into " + tableName +
- " VALUES (?, ?, ?)";
- // Insert all rows at ts
- PreparedStatement pstmt = upsertConn.prepareStatement(updateStmt);
- pstmt.setString(1, tenantId);
- pstmt.setString(2, ROW5);
- pstmt.setString(3, E_VALUE);
- pstmt.execute(); // should commit too
- upsertConn.close();
-
- String query = "SELECT a_string, count(1) FROM " + tableName + " WHERE organization_id='" + tenantId + "' GROUP BY a_string";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2));
- Connection conn = DriverManager.getConnection(getUrl(), props);
- Statement statement = conn.createStatement();
- ResultSet rs = statement.executeQuery(query);
- assertTrue(rs.next());
- assertEquals(A_VALUE, rs.getString(1));
- assertEquals(4, rs.getInt(2));
- assertTrue(rs.next());
- assertEquals(B_VALUE, rs.getString(1));
- assertEquals(3, rs.getLong(2));
- assertTrue(rs.next());
- assertEquals(C_VALUE, rs.getString(1));
- assertEquals(2, rs.getInt(2));
- assertFalse(rs.next());
- conn.close();
- }
-
- @Test
public void testUngroupedAggregation() throws Exception {
String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string = ?";
String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5)); // Execute query at ts + 5
Connection conn = DriverManager.getConnection(url, props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -299,8 +245,6 @@ public class GroupByIT extends BaseQueryIT {
} finally {
conn.close();
}
- // Run again to catch unintentianal deletion of rows during an ungrouped aggregation (W-1455633)
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 6)); // Execute at ts + 6
conn = DriverManager.getConnection(url, props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -318,9 +262,8 @@ public class GroupByIT extends BaseQueryIT {
@Test
public void testUngroupedAggregationNoWhere() throws Exception {
String query = "SELECT count(*) FROM " + tableName;
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(url, props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -334,18 +277,129 @@ public class GroupByIT extends BaseQueryIT {
}
@Test
+ public void testGroupByWithIntegerDivision1() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ String table = generateUniqueName();
+ String ddl = "create table " + table + "(\"time\" integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(\"time\", hostname))";
+ conn.createStatement().execute(ddl);
+ conn.close();
+
+ conn = DriverManager.getConnection(getUrl(), props);
+ PreparedStatement stmt = conn.prepareStatement("upsert into " + table + " values(1439853462,'qa9',8.27,1439853462)");
+ stmt.execute();
+ stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',8.27,1439853362)");
+ stmt.execute();
+ stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',5.27,1439853461)");
+ stmt.execute();
+ stmt = conn.prepareStatement("upsert into " + table + " values(1439853451,'qa9',4.27,1439853451)");
+ stmt.execute();
+ conn.commit();
+ conn.close();
+
+ conn = DriverManager.getConnection(getUrl(), props);
+ ResultSet rs;
+ stmt = conn.prepareStatement("select \"time\"/10 as tm, hostname, avg(usage) from " + table + " group by hostname, tm");
+ rs = stmt.executeQuery();
+ assertTrue(rs.next());
+ assertEquals(143985345, rs.getInt(1));
+ assertEquals(4.2699, rs.getDouble(3), 0.1);
+ assertTrue(rs.next());
+ assertEquals(143985346, rs.getInt(1));
+ assertEquals(6.77, rs.getDouble(3), 0.1);
+ }
+
+ @Test
+ public void testGroupByWithIntegerDivision2() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ String table = generateUniqueName();
+ String ddl = "create table " + table + "(\"time\" integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(\"time\", hostname))";
+ conn.createStatement().execute(ddl);
+ conn.close();
+
+ conn = DriverManager.getConnection(getUrl(), props);
+ PreparedStatement stmt = conn.prepareStatement("upsert into " + table + " values(1439853462,'qa9',8.27,1439853462)");
+ stmt.execute();
+ stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',8.27,1439853362)");
+ stmt.execute();
+ stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',5.27,1439853461)");
+ stmt.execute();
+ stmt = conn.prepareStatement("upsert into " + table + " values(1439853451,'qa9',4.27,1439853451)");
+ stmt.execute();
+ conn.commit();
+ conn.close();
+
+ conn = DriverManager.getConnection(getUrl(), props);
+ ResultSet rs;
+ stmt = conn.prepareStatement("select period/10 as tm, hostname, avg(usage) from " + table + " group by hostname, tm");
+ rs = stmt.executeQuery();
+ assertTrue(rs.next());
+ assertEquals(143985345, rs.getInt(1));
+ assertEquals(4.2699, rs.getDouble(3), 0.1);
+ assertTrue(rs.next());
+ assertEquals(143985346, rs.getInt(1));
+ assertEquals(6.77, rs.getDouble(3), 0.1);
+ }
+
+ @Test
+ public void testPointInTimeGroupedAggregation() throws Exception {
+ String updateStmt =
+ "upsert into " + tableName + " VALUES ('" + tenantId + "','" + ROW5 + "','"
+ + C_VALUE + "')";
+ String url = getUrl();
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ Connection upsertConn = DriverManager.getConnection(url, props);
+ upsertConn.setAutoCommit(true); // Test auto commit
+ Statement stmt = upsertConn.createStatement();
+ stmt.execute(updateStmt); // should commit too
+ upsertConn.close();
+
+ long upsert1Time = System.currentTimeMillis();
+ long timeDelta = 100;
+ Thread.sleep(timeDelta);
+
+ upsertConn = DriverManager.getConnection(url, props);
+ upsertConn.setAutoCommit(true); // Test auto commit
+ updateStmt = "upsert into " + tableName + " VALUES (?, ?, ?)";
+ // Insert all rows at ts
+ PreparedStatement pstmt = upsertConn.prepareStatement(updateStmt);
+ pstmt.setString(1, tenantId);
+ pstmt.setString(2, ROW5);
+ pstmt.setString(3, E_VALUE);
+ pstmt.execute(); // should commit too
+ upsertConn.close();
+
+ long queryTime = upsert1Time + timeDelta / 2;
+ String query =
+ "SELECT a_string, count(1) FROM " + tableName + " WHERE organization_id='"
+ + tenantId + "' GROUP BY a_string";
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ Statement statement = conn.createStatement();
+ ResultSet rs = statement.executeQuery(query);
+ assertTrue(rs.next());
+ assertEquals(A_VALUE, rs.getString(1));
+ assertEquals(4, rs.getInt(2));
+ assertTrue(rs.next());
+ assertEquals(B_VALUE, rs.getString(1));
+ assertEquals(3, rs.getLong(2));
+ assertTrue(rs.next());
+ assertEquals(C_VALUE, rs.getString(1));
+ assertEquals(2, rs.getInt(2));
+ assertFalse(rs.next());
+ conn.close();
+ }
+
+ @Test
public void testPointInTimeUngroupedAggregation() throws Exception {
// Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection upsertConn = DriverManager.getConnection(url, props);
- String updateStmt =
- "upsert into " + tableName +
- " (" +
- " ORGANIZATION_ID, " +
- " ENTITY_ID, " +
- " A_STRING) " +
- "VALUES (?, ?, ?)";
+ String updateStmt =
+ "upsert into " + tableName + " (" + " ORGANIZATION_ID, " + " ENTITY_ID, "
+ + " A_STRING) " + "VALUES (?, ?, ?)";
// Insert all rows at ts
PreparedStatement stmt = upsertConn.prepareStatement(updateStmt);
stmt.setString(1, tenantId);
@@ -359,9 +413,10 @@ public class GroupByIT extends BaseQueryIT {
stmt.execute();
upsertConn.commit();
upsertConn.close();
+ long upsert1Time = System.currentTimeMillis();
+ long timeDelta = 100;
+ Thread.sleep(timeDelta);
- // Override value again, but should be ignored since it's past the SCN
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3); // Run query at timestamp 5
upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
stmt = upsertConn.prepareStatement(updateStmt);
@@ -371,9 +426,11 @@ public class GroupByIT extends BaseQueryIT {
stmt.execute();
upsertConn.close();
- String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string = ?";
+ long queryTime = upsert1Time + timeDelta / 2;
+ String query =
+ "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string = ?";
// Specify CurrentSCN on URL with extra stuff afterwards (which should be ignored)
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 2) + ";foo=bar"; // Run query at timestamp 2
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
Connection conn = DriverManager.getConnection(url, props);
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
@@ -387,15 +444,10 @@ public class GroupByIT extends BaseQueryIT {
@Test
public void testPointInTimeUngroupedLimitedAggregation() throws Exception {
- String updateStmt =
- "upsert into " + tableName +
- " (" +
- " ORGANIZATION_ID, " +
- " ENTITY_ID, " +
- " A_STRING) " +
- "VALUES (?, ?, ?)";
- // Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
+ String updateStmt =
+ "upsert into " + tableName + " (" + " ORGANIZATION_ID, " + " ENTITY_ID, "
+ + " A_STRING) " + "VALUES (?, ?, ?)";
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
@@ -411,9 +463,10 @@ public class GroupByIT extends BaseQueryIT {
stmt.setString(3, B_VALUE);
stmt.execute();
upsertConn.close();
-
- // Override value again, but should be ignored since it's past the SCN
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3); // Run query at timestamp 5
+ long upsert1Time = System.currentTimeMillis();
+ long timeDelta = 100;
+ Thread.sleep(timeDelta);
+
upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
stmt = upsertConn.prepareStatement(updateStmt);
@@ -423,9 +476,12 @@ public class GroupByIT extends BaseQueryIT {
stmt.execute();
upsertConn.close();
- String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string = ? LIMIT 3";
+ long queryTime = upsert1Time + timeDelta / 2;
+ String query =
+ "SELECT count(1) FROM " + tableName
+ + " WHERE organization_id=? and a_string = ? LIMIT 3";
// Specify CurrentSCN on URL with extra stuff afterwards (which should be ignored)
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 2) + ";foo=bar"; // Run query at timestamp 2
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
Connection conn = DriverManager.getConnection(url, props);
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
@@ -436,78 +492,4 @@ public class GroupByIT extends BaseQueryIT {
assertFalse(rs.next());
conn.close();
}
-
- @Test
- public void testGroupByWithIntegerDivision1() throws Exception {
- long ts = nextTimestamp();
- Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
- Connection conn = DriverManager.getConnection(getUrl(), props);
- String table = generateUniqueName();
- String ddl = "create table " + table + "(\"time\" integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(\"time\", hostname))";
- conn.createStatement().execute(ddl);
- conn.close();
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
- conn = DriverManager.getConnection(getUrl(), props);
- PreparedStatement stmt = conn.prepareStatement("upsert into " + table + " values(1439853462,'qa9',8.27,1439853462)");
- stmt.execute();
- stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',8.27,1439853362)");
- stmt.execute();
- stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',5.27,1439853461)");
- stmt.execute();
- stmt = conn.prepareStatement("upsert into " + table + " values(1439853451,'qa9',4.27,1439853451)");
- stmt.execute();
- conn.commit();
- conn.close();
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
- conn = DriverManager.getConnection(getUrl(), props);
- ResultSet rs;
- stmt = conn.prepareStatement("select \"time\"/10 as tm, hostname, avg(usage) from " + table + " group by hostname, tm");
- rs = stmt.executeQuery();
- assertTrue(rs.next());
- assertEquals(143985345, rs.getInt(1));
- assertEquals(4.2699, rs.getDouble(3), 0.1);
- assertTrue(rs.next());
- assertEquals(143985346, rs.getInt(1));
- assertEquals(6.77, rs.getDouble(3), 0.1);
- }
-
- @Test
- public void testGroupByWithIntegerDivision2() throws Exception {
- long ts = nextTimestamp();
- Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
- Connection conn = DriverManager.getConnection(getUrl(), props);
- String table = generateUniqueName();
- String ddl = "create table " + table + "(\"time\" integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(\"time\", hostname))";
- conn.createStatement().execute(ddl);
- conn.close();
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
- conn = DriverManager.getConnection(getUrl(), props);
- PreparedStatement stmt = conn.prepareStatement("upsert into " + table + " values(1439853462,'qa9',8.27,1439853462)");
- stmt.execute();
- stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',8.27,1439853362)");
- stmt.execute();
- stmt = conn.prepareStatement("upsert into " + table + " values(1439853461,'qa9',5.27,1439853461)");
- stmt.execute();
- stmt = conn.prepareStatement("upsert into " + table + " values(1439853451,'qa9',4.27,1439853451)");
- stmt.execute();
- conn.commit();
- conn.close();
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
- conn = DriverManager.getConnection(getUrl(), props);
- ResultSet rs;
- stmt = conn.prepareStatement("select period/10 as tm, hostname, avg(usage) from " + table + " group by hostname, tm");
- rs = stmt.executeQuery();
- assertTrue(rs.next());
- assertEquals(143985345, rs.getInt(1));
- assertEquals(4.2699, rs.getDouble(3), 0.1);
- assertTrue(rs.next());
- assertEquals(143985346, rs.getInt(1));
- assertEquals(6.77, rs.getDouble(3), 0.1);
- }
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java
index dc9b945..770c015 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java
@@ -70,15 +70,12 @@ public class MutableQueryIT extends BaseQueryIT {
public void testSumOverNullIntegerColumn() throws Exception {
String query = "SELECT sum(a_integer) FROM " + tableName + " a";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(true);
conn.createStatement().execute("UPSERT INTO " + tableName + " (organization_id,entity_id,a_integer) VALUES('" + getOrganizationId() + "','" + ROW3 + "',NULL)");
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
Connection conn1 = DriverManager.getConnection(getUrl(), props);
analyzeTable(conn1, tableName);
conn1.close();
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 50));
conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -89,12 +86,10 @@ public class MutableQueryIT extends BaseQueryIT {
} finally {
conn.close();
}
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 70));
conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(true);
conn.createStatement().execute("UPSERT INTO " + tableName + " (organization_id,entity_id,a_integer) SELECT organization_id, entity_id, CAST(null AS integer) FROM " + tableName);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 90));
conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -109,7 +104,7 @@ public class MutableQueryIT extends BaseQueryIT {
}
private void testNoStringValue(String value) throws Exception {
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 10);
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
@@ -122,13 +117,11 @@ public class MutableQueryIT extends BaseQueryIT {
stmt.execute(); // should commit too
upsertConn.close();
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
Connection conn1 = DriverManager.getConnection(getUrl(), props);
analyzeTable(conn1, tableName);
conn1.close();
String query = "SELECT a_string, b_string FROM " + tableName + " WHERE organization_id=? and a_integer = 5";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -157,13 +150,12 @@ public class MutableQueryIT extends BaseQueryIT {
@Test
public void testUnfoundSingleColumnCaseStatement() throws Exception {
String query = "SELECT entity_id, b_string FROM " + tableName + " WHERE organization_id=? and CASE WHEN a_integer = 0 or a_integer != 0 THEN 1 ELSE 0 END = 0";
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(url, props);
// Set ROW5.A_INTEGER to null so that we have one row
// where the else clause of the CASE statement will
// fire.
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
Connection upsertConn = DriverManager.getConnection(url, props);
String upsertStmt =
"upsert into " + tableName +
@@ -191,7 +183,6 @@ public class MutableQueryIT extends BaseQueryIT {
@Test
public void testGroupByCondition() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
Connection conn = DriverManager.getConnection(getUrl(), props);
PreparedStatement statement = conn.prepareStatement("SELECT count(*) FROM " + tableName + " WHERE organization_id=? GROUP BY a_integer=6");
statement.setString(1, tenantId);
@@ -209,8 +200,6 @@ public class MutableQueryIT extends BaseQueryIT {
conn.close();
}
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
conn = DriverManager.getConnection(getUrl(), props);
try {
statement = conn.prepareStatement("UPSERT into " + tableName + " (organization_id,entity_id,a_integer) values(?,?,null)");
@@ -221,7 +210,6 @@ public class MutableQueryIT extends BaseQueryIT {
} finally {
conn.close();
}
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 60));
conn = DriverManager.getConnection(getUrl(), props);
statement = conn.prepareStatement("SELECT count(*) FROM " + tableName + " WHERE organization_id=? GROUP BY a_integer=6");
statement.setString(1, tenantId);
@@ -260,7 +248,7 @@ public class MutableQueryIT extends BaseQueryIT {
"VALUES (?, ?, ?)";
// Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
+ String url = getUrl();// + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
// Remove column value at ts + 1 (i.e. equivalent to setting the value to null)
@@ -278,19 +266,26 @@ public class MutableQueryIT extends BaseQueryIT {
stmt.execute();
conn.commit();
conn.close();
+ long firstDeleteTime = System.currentTimeMillis();
+ long timeDelta = 100;
+ Thread.sleep(timeDelta);
// Delete row at timestamp 3. This should not be seen by the query executing
// Remove column value at ts + 1 (i.e. equivalent to setting the value to null)
- Connection futureConn = DriverManager.getConnection(getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3), props);
+ Connection futureConn = DriverManager.getConnection(getUrl());// + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3), props);
stmt = futureConn.prepareStatement("delete from " + tableName + " where organization_id=? and entity_id=?");
stmt.setString(1, tenantId);
stmt.setString(2, ROW6);
stmt.execute();
futureConn.commit();
futureConn.close();
+
+ // query at a time which is beyong deleteTime1 but before the time at which above delete
+ // happened
+ long queryTime = firstDeleteTime + timeDelta / 2;
String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string = ?";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime)); // Execute at timestamp 2
conn = DriverManager.getConnection(getUrl(), props);
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
@@ -305,9 +300,8 @@ public class MutableQueryIT extends BaseQueryIT {
@Test
public void testPointInTimeScan() throws Exception {
// Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 10);
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- //props.put(QueryServices.DEFAULT_KEEP_DELETED_CELLS_ATTRIB, Boolean.TRUE.toString());
Connection upsertConn = DriverManager.getConnection(url, props);
String upsertStmt =
"upsert into " + tableName +
@@ -317,21 +311,18 @@ public class MutableQueryIT extends BaseQueryIT {
" A_INTEGER) " +
"VALUES (?, ?, ?)";
upsertConn.setAutoCommit(true); // Test auto commit
- // Insert all rows at ts
+ upsertConn.close();
+
PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
stmt.setString(1, tenantId);
stmt.setString(2, ROW4);
stmt.setInt(3, 5);
stmt.execute(); // should commit too
+ long upsert1Time = System.currentTimeMillis();
+ long timeDelta = 100;
+ Thread.sleep(timeDelta);
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 15);
- Connection conn1 = DriverManager.getConnection(url, props);
- analyzeTable(conn1, tableName);
- conn1.close();
- upsertConn.close();
-
// Override value again, but should be ignored since it's past the SCN
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 30);
upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
// Insert all rows at ts
@@ -342,8 +333,9 @@ public class MutableQueryIT extends BaseQueryIT {
stmt.execute(); // should commit too
upsertConn.close();
+ long queryTime = upsert1Time + timeDelta / 2;
String query = "SELECT organization_id, a_string AS a FROM " + tableName + " WHERE organization_id=? and a_integer = 5";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
Connection conn = DriverManager.getConnection(getUrl(), props);
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
@@ -362,7 +354,7 @@ public class MutableQueryIT extends BaseQueryIT {
@Test
public void testPointInTimeLimitedScan() throws Exception {
// Override value that was set at creation time
- String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5
+ String url = getUrl();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection upsertConn = DriverManager.getConnection(url, props);
String upsertStmt =
@@ -380,9 +372,11 @@ public class MutableQueryIT extends BaseQueryIT {
stmt.setInt(3, 6);
stmt.execute(); // should commit too
upsertConn.close();
+ long upsert1Time = System.currentTimeMillis();
+ long timeDelta = 100;
+ Thread.sleep(timeDelta);
- // Override value again, but should be ignored since it's past the SCN
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3);
+ url = getUrl();
upsertConn = DriverManager.getConnection(url, props);
upsertConn.setAutoCommit(true); // Test auto commit
// Insert all rows at ts
@@ -393,8 +387,9 @@ public class MutableQueryIT extends BaseQueryIT {
stmt.execute(); // should commit too
upsertConn.close();
+ long queryTime = upsert1Time + timeDelta / 2;
String query = "SELECT a_integer,b_string FROM " + tableName + " WHERE organization_id=? and a_integer <= 5 limit 2";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2));
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
Connection conn = DriverManager.getConnection(getUrl(), props);
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java
index 3b868d0..9a285ff 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java
@@ -65,7 +65,6 @@ public class NotQueryIT extends BaseQueryIT {
public void testNotInList() throws Exception {
String query = "SELECT entity_id FROM " + tableName + " WHERE organization_id=? and entity_id NOT IN (?,?,?,?,?,?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -93,7 +92,6 @@ public class NotQueryIT extends BaseQueryIT {
public void testNotInListOfFloat() throws Exception {
String query = "SELECT a_float FROM " + tableName + " WHERE organization_id=? and a_float NOT IN (?,?,?,?,?,?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -121,7 +119,6 @@ public class NotQueryIT extends BaseQueryIT {
public void testNotInListOfDouble() throws Exception {
String query = "SELECT a_double FROM " + tableName + " WHERE organization_id=? and a_double NOT IN (?,?,?,?,?,?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -150,7 +147,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT entity_id -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_integer != 1 and a_integer <= 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -169,7 +165,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT a_byte -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_byte != 1 and a_byte <= 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -188,7 +183,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT a_short -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_short != 128 and a_short !=0 and a_short <= 129";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -207,7 +201,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT a_float -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_float != CAST(0.01 AS FLOAT) and a_float <= CAST(0.02 AS FLOAT)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -226,7 +219,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT a_unsigned_float -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_unsigned_float != 0.01 and a_unsigned_float <= 0.02";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -245,7 +237,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT a_double -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_double != CAST(0.0001 AS DOUBLE) and a_double <= CAST(0.0002 AS DOUBLE)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -264,7 +255,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT a_unsigned_double -- and here comment\n" +
"FROM " + tableName + " WHERE organization_id=? and a_unsigned_double != 0.0001 and a_unsigned_double <= 0.0002";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
@@ -283,7 +273,6 @@ public class NotQueryIT extends BaseQueryIT {
String query = "SELECT entity_id FROM // one more comment \n" + tableName +
" WHERE organization_id=? and not a_integer = 1 and a_integer <= 2";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
Connection conn = DriverManager.getConnection(getUrl(), props);
try {
PreparedStatement statement = conn.prepareStatement(query);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3bb174b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java
deleted file mode 100644
index 0390c03..0000000
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.phoenix.end2end;
-
-import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.util.Properties;
-
-import org.apache.phoenix.schema.SequenceNotFoundException;
-import org.apache.phoenix.util.PhoenixRuntime;
-import org.apache.phoenix.util.PropertiesUtil;
-import org.junit.Test;
-
-public class PointInTimeQueryIT extends BaseQueryIT {
-
- public PointInTimeQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) throws Exception {
- super(indexDDL, mutable, columnEncoded, true);
- }
-
- @Test
- public void testPointInTimeSequence() throws Exception {
- Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- Connection conn;
- ResultSet rs;
- String seqName = generateUniqueName();
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+5));
- conn = DriverManager.getConnection(getUrl(), props);
- conn.createStatement().execute("CREATE SEQUENCE " + seqName + "");
-
- try {
- conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- fail();
- } catch (SequenceNotFoundException e) {
- conn.close();
- }
-
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+10));
- conn = DriverManager.getConnection(getUrl(), props);
- rs = conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- assertTrue(rs.next());
- assertEquals(1, rs.getInt(1));
- conn.close();
-
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+7));
- conn = DriverManager.getConnection(getUrl(), props);
- rs = conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- assertTrue(rs.next());
- assertEquals(2, rs.getInt(1));
- conn.close();
-
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+15));
- conn = DriverManager.getConnection(getUrl(), props);
- conn.createStatement().execute("DROP SEQUENCE " + seqName + "");
- rs = conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- assertTrue(rs.next());
- assertEquals(3, rs.getInt(1));
- conn.close();
-
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+20));
- conn = DriverManager.getConnection(getUrl(), props);
- try {
- rs = conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- fail();
- } catch (SequenceNotFoundException e) { // expected
- }
-
- conn.createStatement().execute("CREATE SEQUENCE " + seqName);
- conn.close();
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+25));
- conn = DriverManager.getConnection(getUrl(), props);
- rs = conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- assertTrue(rs.next());
- assertEquals(1, rs.getInt(1));
- conn.close();
-
- props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+6));
- conn = DriverManager.getConnection(getUrl(), props);
- rs = conn.createStatement().executeQuery("SELECT next value for " + seqName + " FROM " + tableName + " LIMIT 1");
- assertTrue(rs.next());
- assertEquals(4, rs.getInt(1));
- conn.close();
- }
-
-}