You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2017/02/13 19:44:50 UTC
[3/3] phoenix git commit: PHOENIX-3446 Parameterize tests for
different encoding and storage schemes
PHOENIX-3446 Parameterize tests for different encoding and storage schemes
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e89337f8
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e89337f8
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e89337f8
Branch: refs/heads/encodecolumns2
Commit: e89337f836922b50ab265f3009ca6cf2a07401ca
Parents: 3b6709d
Author: Thomas D'Silva <td...@salesforce.com>
Authored: Tue Feb 7 12:55:32 2017 -0800
Committer: Thomas D'Silva <td...@salesforce.com>
Committed: Mon Feb 13 11:43:32 2017 -0800
----------------------------------------------------------------------
.../phoenix/end2end/AggregateQueryIT.java | 47 +-
.../org/apache/phoenix/end2end/BaseJoinIT.java | 4 +-
.../org/apache/phoenix/end2end/BaseQueryIT.java | 59 +-
.../apache/phoenix/end2end/CaseStatementIT.java | 37 +-
.../apache/phoenix/end2end/CastAndCoerceIT.java | 4 +-
.../end2end/ClientTimeArithmeticQueryIT.java | 4 +-
.../end2end/CountDistinctCompressionIT.java | 2 +-
.../org/apache/phoenix/end2end/DateTimeIT.java | 2 +-
.../apache/phoenix/end2end/DerivedTableIT.java | 2 +-
.../apache/phoenix/end2end/DistinctCountIT.java | 4 +-
.../phoenix/end2end/ExtendedQueryExecIT.java | 8 +-
.../apache/phoenix/end2end/FunkyNamesIT.java | 2 +-
.../org/apache/phoenix/end2end/GroupByIT.java | 124 +---
.../apache/phoenix/end2end/MutableQueryIT.java | 424 ++++++++++++++
.../phoenix/end2end/NativeHBaseTypesIT.java | 2 +-
.../org/apache/phoenix/end2end/NotQueryIT.java | 4 +-
.../apache/phoenix/end2end/PercentileIT.java | 4 +-
.../phoenix/end2end/PointInTimeQueryIT.java | 64 +-
.../phoenix/end2end/ProductMetricsIT.java | 2 +-
.../end2end/QueryDatabaseMetaDataIT.java | 16 +-
.../org/apache/phoenix/end2end/QueryIT.java | 50 +-
.../phoenix/end2end/ReadIsolationLevelIT.java | 2 +-
.../phoenix/end2end/RowValueConstructorIT.java | 34 +-
.../org/apache/phoenix/end2end/ScanQueryIT.java | 61 +-
.../java/org/apache/phoenix/end2end/TopNIT.java | 6 +-
.../apache/phoenix/end2end/UpsertSelectIT.java | 10 +-
.../apache/phoenix/end2end/UpsertValuesIT.java | 6 +-
.../phoenix/end2end/VariableLengthPKIT.java | 38 +-
.../phoenix/end2end/index/ImmutableIndexIT.java | 20 +-
.../apache/phoenix/end2end/index/IndexIT.java | 30 +-
.../phoenix/end2end/index/MutableIndexIT.java | 17 +-
.../phoenix/end2end/salted/SaltedTableIT.java | 2 +-
.../phoenix/tx/ParameterizedTransactionIT.java | 518 ++++++++++++++++
.../org/apache/phoenix/tx/TransactionIT.java | 587 +++----------------
.../org/apache/phoenix/tx/TxCheckpointIT.java | 42 +-
.../compile/TupleProjectionCompiler.java | 7 +-
.../java/org/apache/phoenix/query/BaseTest.java | 33 +-
37 files changed, 1252 insertions(+), 1026 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 c689373..f017c00 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
@@ -22,7 +22,6 @@ import static org.apache.phoenix.util.TestUtil.A_VALUE;
import static org.apache.phoenix.util.TestUtil.B_VALUE;
import static org.apache.phoenix.util.TestUtil.C_VALUE;
import static org.apache.phoenix.util.TestUtil.E_VALUE;
-import static org.apache.phoenix.util.TestUtil.ROW3;
import static org.apache.phoenix.util.TestUtil.ROW4;
import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import static org.junit.Assert.assertEquals;
@@ -47,50 +46,8 @@ import org.junit.Test;
public class AggregateQueryIT extends BaseQueryIT {
- public AggregateQueryIT(String indexDDL) {
- super(indexDDL);
- }
-
- @Test
- public void testSumOverNullIntegerColumn() throws Exception {
- String query = "SELECT sum(a_integer) FROM aTable 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 atable(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, "ATABLE");
- conn1.close();
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 50));
- conn = DriverManager.getConnection(getUrl(), props);
- try {
- PreparedStatement statement = conn.prepareStatement(query);
- ResultSet rs = statement.executeQuery();
- assertTrue (rs.next());
- assertEquals(42, rs.getInt(1));
- assertFalse(rs.next());
- } 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 atable(organization_id,entity_id,a_integer) SELECT organization_id, entity_id, CAST(null AS integer) FROM atable");
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 90));
- conn = DriverManager.getConnection(getUrl(), props);
- try {
- PreparedStatement statement = conn.prepareStatement(query);
- ResultSet rs = statement.executeQuery();
- assertTrue (rs.next());
- assertEquals(0, rs.getInt(1));
- assertTrue(rs.wasNull());
- assertFalse(rs.next());
- } finally {
- conn.close();
- }
+ public AggregateQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseJoinIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseJoinIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseJoinIT.java
index f1c1808..152bdf0 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseJoinIT.java
@@ -60,14 +60,14 @@ public abstract class BaseJoinIT extends ParallelStatsDisabledIT {
" \"item_id\" varchar(10), " +
" price integer, " +
" quantity integer, " +
- " date timestamp)");
+ " date timestamp) IMMUTABLE_ROWS=true");
builder.put(JOIN_CUSTOMER_TABLE_FULL_NAME, "create table " + JOIN_CUSTOMER_TABLE_FULL_NAME +
" (\"customer_id\" varchar(10) not null primary key, " +
" name varchar, " +
" phone varchar(12), " +
" address varchar, " +
" loc_id varchar(5), " +
- " date date)");
+ " date date) IMMUTABLE_ROWS=true");
builder.put(JOIN_ITEM_TABLE_FULL_NAME, "create table " + JOIN_ITEM_TABLE_FULL_NAME +
" (\"item_id\" varchar(10) not null primary key, " +
" name varchar, " +
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 9ad12e5..1ab9c73 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
@@ -17,8 +17,8 @@
*/
package org.apache.phoenix.end2end;
-import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import static org.apache.phoenix.util.TestUtil.ATABLE_NAME;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import java.io.IOException;
import java.sql.Connection;
@@ -30,10 +30,12 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
+
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
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;
@@ -61,6 +63,21 @@ public abstract class BaseQueryIT extends BaseClientManagedTimeIT {
protected static final String tenantId = getOrganizationId();
protected static final String ATABLE_INDEX_NAME = "ATABLE_IDX";
protected static final long BATCH_SIZE = 3;
+ protected static final String[] INDEX_DDLS = new String[] {
+ "CREATE INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer DESC) INCLUDE ("
+ + " A_STRING, " + " B_STRING, " + " A_DATE)",
+ "CREATE INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer, a_string) INCLUDE ("
+ + " B_STRING, " + " A_DATE)",
+ "CREATE INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer) INCLUDE ("
+ + " A_STRING, " + " B_STRING, " + " A_DATE)",
+ "CREATE LOCAL INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer DESC) INCLUDE ("
+ + " A_STRING, " + " B_STRING, " + " A_DATE)",
+ "CREATE LOCAL INDEX " + ATABLE_INDEX_NAME
+ + " ON aTable (a_integer, a_string) INCLUDE (" + " B_STRING, "
+ + " A_DATE)",
+ "CREATE LOCAL INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer) INCLUDE ("
+ + " A_STRING, " + " B_STRING, " + " A_DATE)",
+ "" };
@BeforeClass
@Shadower(classBeingShadowed = BaseClientManagedTimeIT.class)
@@ -82,15 +99,29 @@ public abstract class BaseQueryIT extends BaseClientManagedTimeIT {
protected long ts;
protected Date date;
private String indexDDL;
+ private String tableDDLOptions;
- public BaseQueryIT(String indexDDL) {
+ public BaseQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
this.indexDDL = indexDDL;
+ StringBuilder optionBuilder = new StringBuilder();
+ if (!columnEncoded) {
+ optionBuilder.append("COLUMN_ENCODED_BYTES=0");
+ }
+ if (!mutable) {
+ if (optionBuilder.length()>0)
+ optionBuilder.append(",");
+ optionBuilder.append("IMMUTABLE_ROWS=true");
+ if (!columnEncoded) {
+ optionBuilder.append(",IMMUTABLE_STORAGE_SCHEME="+PTableImpl.ImmutableStorageScheme.ONE_CELL_PER_COLUMN);
+ }
+ }
+ this.tableDDLOptions = optionBuilder.toString();
}
@Before
public void initTable() throws Exception {
ts = nextTimestamp();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), date=new Date(System.currentTimeMillis()), ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), date=new Date(System.currentTimeMillis()), ts, getUrl(), tableDDLOptions);
if (indexDDL != null && indexDDL.length() > 0) {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
@@ -99,22 +130,16 @@ public abstract class BaseQueryIT extends BaseClientManagedTimeIT {
}
}
- @Parameters(name="{0}")
+ @Parameters(name="indexDDL={0},mutable={1},columnEncoded={2}")
public static Collection<Object> data() {
List<Object> testCases = Lists.newArrayList();
- testCases.add(new String[] { "CREATE INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer DESC) INCLUDE ("
- + " A_STRING, " + " B_STRING, " + " A_DATE)" });
- testCases.add(new String[] { "CREATE INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer, a_string) INCLUDE ("
- + " B_STRING, " + " A_DATE)" });
- testCases.add(new String[] { "CREATE INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer) INCLUDE ("
- + " A_STRING, " + " B_STRING, " + " A_DATE)" });
- testCases.add(new String[] { "CREATE LOCAL INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer DESC) INCLUDE ("
- + " A_STRING, " + " B_STRING, " + " A_DATE)" });
- testCases.add(new String[] { "CREATE LOCAL INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer, a_string) INCLUDE ("
- + " B_STRING, " + " A_DATE)" });
- testCases.add(new String[] { "CREATE LOCAL INDEX " + ATABLE_INDEX_NAME + " ON aTable (a_integer) INCLUDE ("
- + " A_STRING, " + " B_STRING, " + " A_DATE)" });
- testCases.add(new String[] { "" });
+ for (String indexDDL : INDEX_DDLS) {
+ for (boolean mutable : new boolean[]{false,true}) {
+ for (boolean columnEncoded : new boolean[]{false,true}) {
+ testCases.add(new Object[] { indexDDL, mutable, columnEncoded });
+ }
+ }
+ }
return testCases;
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 59b0f41..6aa2975 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
@@ -54,8 +54,8 @@ import com.google.common.collect.Lists;
@RunWith(Parameterized.class)
public class CaseStatementIT extends BaseQueryIT {
- public CaseStatementIT(String indexDDL) {
- super(indexDDL);
+ public CaseStatementIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Parameters(name="CaseStatementIT_{index}") // name is used by failsafe as file name in reports
@@ -177,39 +177,6 @@ public class CaseStatementIT extends BaseQueryIT {
}
@Test
- public void testUnfoundSingleColumnCaseStatement() throws Exception {
- String query = "SELECT entity_id, b_string FROM ATABLE 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
- 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 " +
- "ATABLE(" +
- " ENTITY_ID, " +
- " ORGANIZATION_ID, " +
- " A_INTEGER) " +
- "VALUES ('" + ROW5 + "','" + tenantId + "', null)";
- upsertConn.setAutoCommit(true); // Test auto commit
- // Insert all rows at ts
- PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
- stmt.execute(); // should commit too
- upsertConn.close();
-
- PreparedStatement statement = conn.prepareStatement(query);
- statement.setString(1, tenantId);
- ResultSet rs = statement.executeQuery();
- assertTrue(rs.next());
- assertEquals(ROW5, rs.getString(1));
- assertFalse(rs.next());
- conn.close();
- }
-
- @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 ATABLE WHERE organization_id=?";
String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 876c23a..08723a6 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
@@ -43,8 +43,8 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class CastAndCoerceIT extends BaseQueryIT {
- public CastAndCoerceIT(String indexDDL) {
- super(indexDDL);
+ public CastAndCoerceIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Parameters(name="CastAndCoerceIT_{index}") // name is used by failsafe as file name in reports
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 ea4f3ab..5f1caa3 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
@@ -60,8 +60,8 @@ import com.google.common.collect.Lists;
@RunWith(Parameterized.class)
public class ClientTimeArithmeticQueryIT extends BaseQueryIT {
- public ClientTimeArithmeticQueryIT(String indexDDL) {
- super(indexDDL);
+ public ClientTimeArithmeticQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Parameters(name="ClientTimeArithmeticQueryIT_{index}") // name is used by failsafe as file name in reports
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java
index 1539ad7..db4542e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java
@@ -51,7 +51,7 @@ public class CountDistinctCompressionIT extends BaseUniqueNamesOwnClusterIT {
@Test
public void testDistinctCountOnColumn() throws Exception {
String tenantId = getOrganizationId();
- String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), (Date)null, null, getUrl());
+ String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), (Date)null, null, getUrl(), null);
String query = "SELECT count(DISTINCT A_STRING) FROM " + tableName;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
index 74cc068..c7fc59c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java
@@ -76,7 +76,7 @@ public class DateTimeIT extends ParallelStatsDisabledIT {
private String initAtable() throws SQLException {
String tableName = generateUniqueName();
- ensureTableCreated(getUrl(), tableName, ATABLE_NAME, (byte[][])null);
+ ensureTableCreated(getUrl(), tableName, ATABLE_NAME, (byte[][])null, null);
PreparedStatement stmt = conn.prepareStatement(
"upsert into " + tableName +
"(" +
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
index be6b48e..224bb44 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
@@ -73,7 +73,7 @@ public class DerivedTableIT extends BaseClientManagedTimeIT {
@Before
public void initTable() throws Exception {
ts = nextTimestamp();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
if (indexDDL != null && indexDDL.length > 0) {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java
index 4484fc1..a7482cb 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java
@@ -287,9 +287,9 @@ public class DistinctCountIT extends BaseClientManagedTimeIT {
protected static void initATableValues(String tenantId1, String tenantId2, byte[][] splits, Date date, Long ts) throws Exception {
if (ts == null) {
- ensureTableCreated(getUrl(), ATABLE_NAME, ATABLE_NAME, splits);
+ ensureTableCreated(getUrl(), ATABLE_NAME, ATABLE_NAME, splits, null);
} else {
- ensureTableCreated(getUrl(), ATABLE_NAME, ATABLE_NAME, splits, ts-2);
+ ensureTableCreated(getUrl(), ATABLE_NAME, ATABLE_NAME, splits, ts-2, null);
}
Properties props = new Properties();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java
index f5c1df2..f46b3e4 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java
@@ -52,7 +52,7 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT {
Date date = new Date(1);
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl(), null);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1));
@@ -75,7 +75,7 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT {
public void testTypeMismatchToDateFunctionBind() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),null, ts, getUrl(), null);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
@@ -103,7 +103,7 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT {
Date date = new Date(1);
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl(), null);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1));
Connection conn = DriverManager.getConnection(getUrl(), props);
@@ -148,7 +148,7 @@ public class ExtendedQueryExecIT extends BaseClientManagedTimeIT {
Date date = new Date(1);
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId),date, ts, getUrl(), null);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1));
Connection conn = DriverManager.getConnection(getUrl(), props);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java
index 26e13eb..131e146 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java
@@ -39,7 +39,7 @@ import org.junit.Test;
public class FunkyNamesIT extends BaseClientManagedTimeIT {
protected static void initTableValues(byte[][] splits, long ts) throws Exception {
- ensureTableCreated(getUrl(), FUNKY_NAME, FUNKY_NAME,splits, ts-2);
+ ensureTableCreated(getUrl(), FUNKY_NAME, FUNKY_NAME,splits, ts-2, null);
String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts;
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 f0c781f..1180e25 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
@@ -21,7 +21,6 @@ import static org.apache.phoenix.util.TestUtil.A_VALUE;
import static org.apache.phoenix.util.TestUtil.B_VALUE;
import static org.apache.phoenix.util.TestUtil.C_VALUE;
import static org.apache.phoenix.util.TestUtil.E_VALUE;
-import static org.apache.phoenix.util.TestUtil.ROW3;
import static org.apache.phoenix.util.TestUtil.ROW5;
import static org.apache.phoenix.util.TestUtil.ROW6;
import static org.apache.phoenix.util.TestUtil.ROW7;
@@ -35,9 +34,7 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -50,15 +47,14 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@RunWith(Parameterized.class)
public class GroupByIT extends BaseQueryIT {
- public GroupByIT(String indexDDL) {
- super(indexDDL);
+ public GroupByIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Parameters(name="GroupByIT_{index}") // name is used by failsafe as file name in reports
@@ -74,68 +70,6 @@ public class GroupByIT extends BaseQueryIT {
BaseQueryIT.doSetup(props);
}
- @SuppressWarnings("unchecked")
- @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 aTable WHERE organization_id=? GROUP BY a_integer=6");
- statement.setString(1, tenantId);
- ResultSet rs = statement.executeQuery();
- assertValueEqualsResultSet(rs, Arrays.<Object>asList(1L,8L));
- try {
- statement = conn.prepareStatement("SELECT count(*),a_integer=6 FROM aTable WHERE organization_id=? and (a_integer IN (5,6) or a_integer is null) GROUP BY a_integer=6");
- statement.setString(1, tenantId);
- rs = statement.executeQuery();
- List<List<Object>> expectedResults = Lists.newArrayList(
- Arrays.<Object>asList(1L,false),
- Arrays.<Object>asList(1L,true));
- assertValuesEqualsResultSet(rs, expectedResults);
- } finally {
- conn.close();
- }
-
-
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
- conn = DriverManager.getConnection(getUrl(), props);
- try {
- statement = conn.prepareStatement("UPSERT into aTable(organization_id,entity_id,a_integer) values(?,?,null)");
- statement.setString(1, tenantId);
- statement.setString(2, ROW3);
- statement.executeUpdate();
- conn.commit();
- } finally {
- conn.close();
- }
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 60));
- conn = DriverManager.getConnection(getUrl(), props);
- statement = conn.prepareStatement("SELECT count(*) FROM aTable WHERE organization_id=? GROUP BY a_integer=6");
- statement.setString(1, tenantId);
- rs = statement.executeQuery();
- assertValueEqualsResultSet(rs, Arrays.<Object>asList(1L,1L,7L));
- statement = conn.prepareStatement("SELECT a_integer, entity_id FROM aTable WHERE organization_id=? and (a_integer IN (5,6) or a_integer is null)");
- statement.setString(1, tenantId);
- rs = statement.executeQuery();
- List<List<Object>> expectedResults = Lists.newArrayList(
- Arrays.<Object>asList(null,ROW3),
- Arrays.<Object>asList(5,ROW5),
- Arrays.<Object>asList(6,ROW6));
- assertValuesEqualsResultSet(rs, expectedResults);
- try {
- statement = conn.prepareStatement("SELECT count(*),a_integer=6 FROM aTable WHERE organization_id=? and (a_integer IN (5,6) or a_integer is null) GROUP BY a_integer=6");
- statement.setString(1, tenantId);
- rs = statement.executeQuery();
- expectedResults = Lists.newArrayList(
- Arrays.<Object>asList(1L,null),
- Arrays.<Object>asList(1L,false),
- Arrays.<Object>asList(1L,true));
- assertValuesEqualsResultSet(rs, expectedResults);
- } finally {
- conn.close();
- }
- }
-
@Test
public void testNoWhereScan() throws Exception {
String query = "SELECT y_integer FROM aTable";
@@ -517,60 +451,6 @@ public class GroupByIT extends BaseQueryIT {
}
@Test
- public void testPointInTimeDeleteUngroupedAggregation() throws Exception {
- String updateStmt =
- "upsert into " +
- "ATABLE(" +
- " 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
- Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-
- // Remove column value at ts + 1 (i.e. equivalent to setting the value to null)
- Connection conn = DriverManager.getConnection(url, props);
- PreparedStatement stmt = conn.prepareStatement(updateStmt);
- stmt.setString(1, tenantId);
- stmt.setString(2, ROW7);
- stmt.setString(3, null);
- stmt.execute();
-
- // Delete row
- stmt = conn.prepareStatement("delete from atable where organization_id=? and entity_id=?");
- stmt.setString(1, tenantId);
- stmt.setString(2, ROW5);
- stmt.execute();
- conn.commit();
- conn.close();
-
- // 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);
- stmt = futureConn.prepareStatement("delete from atable where organization_id=? and entity_id=?");
- stmt.setString(1, tenantId);
- stmt.setString(2, ROW6);
- stmt.execute();
- futureConn.commit();
- futureConn.close();
-
- String query = "SELECT count(1) FROM atable WHERE organization_id=? and a_string = ?";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
- conn = DriverManager.getConnection(getUrl(), props);
- PreparedStatement statement = conn.prepareStatement(query);
- statement.setString(1, tenantId);
- statement.setString(2, B_VALUE);
- ResultSet rs = statement.executeQuery();
- assertTrue(rs.next());
- assertEquals(2, rs.getLong(1));
- assertFalse(rs.next());
- conn.close();
- }
-
-
- @Test
public void testGroupByWithIntegerDivision1() throws Exception {
long ts = nextTimestamp();
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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
new file mode 100644
index 0000000..ffeb87c
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java
@@ -0,0 +1,424 @@
+/*
+ * 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.A_VALUE;
+import static org.apache.phoenix.util.TestUtil.B_VALUE;
+import static org.apache.phoenix.util.TestUtil.C_VALUE;
+import static org.apache.phoenix.util.TestUtil.E_VALUE;
+import static org.apache.phoenix.util.TestUtil.ROW1;
+import static org.apache.phoenix.util.TestUtil.ROW3;
+import static org.apache.phoenix.util.TestUtil.ROW4;
+import static org.apache.phoenix.util.TestUtil.ROW5;
+import static org.apache.phoenix.util.TestUtil.ROW6;
+import static org.apache.phoenix.util.TestUtil.ROW7;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class MutableQueryIT extends BaseQueryIT {
+
+ @Parameters(name="indexDDL={0},mutable={1},columnEncoded={2}")
+ @Shadower(classBeingShadowed = BaseQueryIT.class)
+ public static Collection<Object> data() {
+ List<Object> testCases = Lists.newArrayList();
+ for (String indexDDL : INDEX_DDLS) {
+ for (boolean columnEncoded : new boolean[]{false,true}) {
+ testCases.add(new Object[] { indexDDL, true, columnEncoded });
+ }
+ }
+ return testCases;
+ }
+
+ @BeforeClass
+ @Shadower(classBeingShadowed = BaseQueryIT.class)
+ public static void doSetup() throws Exception {
+ Map<String,String> props = Maps.newHashMapWithExpectedSize(3);
+ props.put(QueryServices.DEFAULT_KEEP_DELETED_CELLS_ATTRIB, Boolean.TRUE.toString());
+ BaseQueryIT.doSetup(props);
+ }
+
+ public MutableQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
+ }
+
+ @Test
+ public void testSumOverNullIntegerColumn() throws Exception {
+ String query = "SELECT sum(a_integer) FROM aTable 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 atable(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, "ATABLE");
+ conn1.close();
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 50));
+ conn = DriverManager.getConnection(getUrl(), props);
+ try {
+ PreparedStatement statement = conn.prepareStatement(query);
+ ResultSet rs = statement.executeQuery();
+ assertTrue (rs.next());
+ assertEquals(42, rs.getInt(1));
+ assertFalse(rs.next());
+ } 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 atable(organization_id,entity_id,a_integer) SELECT organization_id, entity_id, CAST(null AS integer) FROM atable");
+
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 90));
+ conn = DriverManager.getConnection(getUrl(), props);
+ try {
+ PreparedStatement statement = conn.prepareStatement(query);
+ ResultSet rs = statement.executeQuery();
+ assertTrue (rs.next());
+ assertEquals(0, rs.getInt(1));
+ assertTrue(rs.wasNull());
+ assertFalse(rs.next());
+ } finally {
+ conn.close();
+ }
+ }
+
+ private void testNoStringValue(String value) throws Exception {
+ 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
+ // Insert all rows at ts
+ PreparedStatement stmt = upsertConn.prepareStatement(
+ "upsert into ATABLE VALUES (?, ?, ?)"); // without specifying columns
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW5);
+ stmt.setString(3, value);
+ 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, "ATABLE");
+ conn1.close();
+
+ String query = "SELECT a_string, b_string FROM aTable 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);
+ statement.setString(1, tenantId);
+ ResultSet rs = statement.executeQuery();
+ assertTrue (rs.next());
+ assertEquals(null, rs.getString(1));
+ assertTrue(rs.wasNull());
+ assertEquals(C_VALUE, rs.getString("B_string"));
+ assertFalse(rs.next());
+ } finally {
+ conn.close();
+ }
+ }
+
+ @Test
+ public void testNullStringValue() throws Exception {
+ testNoStringValue(null);
+ }
+
+ @Test
+ public void testEmptyStringValue() throws Exception {
+ testNoStringValue("");
+ }
+
+ @Test
+ public void testUnfoundSingleColumnCaseStatement() throws Exception {
+ String query = "SELECT entity_id, b_string FROM ATABLE 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
+ 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 " +
+ "ATABLE(" +
+ " ENTITY_ID, " +
+ " ORGANIZATION_ID, " +
+ " A_INTEGER) " +
+ "VALUES ('" + ROW5 + "','" + tenantId + "', null)";
+ upsertConn.setAutoCommit(true); // Test auto commit
+ // Insert all rows at ts
+ PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
+ stmt.execute(); // should commit too
+ upsertConn.close();
+
+ PreparedStatement statement = conn.prepareStatement(query);
+ statement.setString(1, tenantId);
+ ResultSet rs = statement.executeQuery();
+ assertTrue(rs.next());
+ assertEquals(ROW5, rs.getString(1));
+ assertFalse(rs.next());
+ conn.close();
+ }
+
+ @SuppressWarnings("unchecked")
+ @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 aTable WHERE organization_id=? GROUP BY a_integer=6");
+ statement.setString(1, tenantId);
+ ResultSet rs = statement.executeQuery();
+ assertValueEqualsResultSet(rs, Arrays.<Object>asList(1L,8L));
+ try {
+ statement = conn.prepareStatement("SELECT count(*),a_integer=6 FROM aTable WHERE organization_id=? and (a_integer IN (5,6) or a_integer is null) GROUP BY a_integer=6");
+ statement.setString(1, tenantId);
+ rs = statement.executeQuery();
+ List<List<Object>> expectedResults = Lists.newArrayList(
+ Arrays.<Object>asList(1L,false),
+ Arrays.<Object>asList(1L,true));
+ assertValuesEqualsResultSet(rs, expectedResults);
+ } finally {
+ conn.close();
+ }
+
+
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40));
+ conn = DriverManager.getConnection(getUrl(), props);
+ try {
+ statement = conn.prepareStatement("UPSERT into aTable(organization_id,entity_id,a_integer) values(?,?,null)");
+ statement.setString(1, tenantId);
+ statement.setString(2, ROW3);
+ statement.executeUpdate();
+ conn.commit();
+ } finally {
+ conn.close();
+ }
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 60));
+ conn = DriverManager.getConnection(getUrl(), props);
+ statement = conn.prepareStatement("SELECT count(*) FROM aTable WHERE organization_id=? GROUP BY a_integer=6");
+ statement.setString(1, tenantId);
+ rs = statement.executeQuery();
+ assertValueEqualsResultSet(rs, Arrays.<Object>asList(1L,1L,7L));
+ statement = conn.prepareStatement("SELECT a_integer, entity_id FROM aTable WHERE organization_id=? and (a_integer IN (5,6) or a_integer is null)");
+ statement.setString(1, tenantId);
+ rs = statement.executeQuery();
+ List<List<Object>> expectedResults = Lists.newArrayList(
+ Arrays.<Object>asList(null,ROW3),
+ Arrays.<Object>asList(5,ROW5),
+ Arrays.<Object>asList(6,ROW6));
+ assertValuesEqualsResultSet(rs, expectedResults);
+ try {
+ statement = conn.prepareStatement("SELECT count(*),a_integer=6 FROM aTable WHERE organization_id=? and (a_integer IN (5,6) or a_integer is null) GROUP BY a_integer=6");
+ statement.setString(1, tenantId);
+ rs = statement.executeQuery();
+ expectedResults = Lists.newArrayList(
+ Arrays.<Object>asList(1L,null),
+ Arrays.<Object>asList(1L,false),
+ Arrays.<Object>asList(1L,true));
+ assertValuesEqualsResultSet(rs, expectedResults);
+ } finally {
+ conn.close();
+ }
+ }
+
+ @Test
+ public void testPointInTimeDeleteUngroupedAggregation() throws Exception {
+ String updateStmt =
+ "upsert into " +
+ "ATABLE(" +
+ " 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
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+
+ // Remove column value at ts + 1 (i.e. equivalent to setting the value to null)
+ Connection conn = DriverManager.getConnection(url, props);
+ PreparedStatement stmt = conn.prepareStatement(updateStmt);
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW7);
+ stmt.setString(3, null);
+ stmt.execute();
+
+ // Delete row
+ stmt = conn.prepareStatement("delete from atable where organization_id=? and entity_id=?");
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW5);
+ stmt.execute();
+ conn.commit();
+ conn.close();
+
+ // 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);
+ stmt = futureConn.prepareStatement("delete from atable where organization_id=? and entity_id=?");
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW6);
+ stmt.execute();
+ futureConn.commit();
+ futureConn.close();
+
+ String query = "SELECT count(1) FROM atable WHERE organization_id=? and a_string = ?";
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
+ conn = DriverManager.getConnection(getUrl(), props);
+ PreparedStatement statement = conn.prepareStatement(query);
+ statement.setString(1, tenantId);
+ statement.setString(2, B_VALUE);
+ ResultSet rs = statement.executeQuery();
+ assertTrue(rs.next());
+ assertEquals(2, rs.getLong(1));
+ assertFalse(rs.next());
+ conn.close();
+ }
+
+ @Test
+ public void testPointInTimeScan() throws Exception {
+ // 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);
+ String upsertStmt =
+ "upsert into " +
+ "ATABLE(" +
+ " ORGANIZATION_ID, " +
+ " ENTITY_ID, " +
+ " A_INTEGER) " +
+ "VALUES (?, ?, ?)";
+ upsertConn.setAutoCommit(true); // Test auto commit
+ // Insert all rows at ts
+ PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW4);
+ stmt.setInt(3, 5);
+ stmt.execute(); // should commit too
+
+ url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 15);
+ Connection conn1 = DriverManager.getConnection(url, props);
+ analyzeTable(conn1, "ATABLE");
+ 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
+ stmt = upsertConn.prepareStatement(upsertStmt);
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW4);
+ stmt.setInt(3, 9);
+ stmt.execute(); // should commit too
+ upsertConn.close();
+
+ String query = "SELECT organization_id, a_string AS a FROM atable WHERE organization_id=? and a_integer = 5";
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ PreparedStatement statement = conn.prepareStatement(query);
+ statement.setString(1, tenantId);
+ ResultSet rs = statement.executeQuery();
+ assertTrue(rs.next());
+ assertEquals(tenantId, rs.getString(1));
+ assertEquals(A_VALUE, rs.getString("a"));
+ assertTrue(rs.next());
+ assertEquals(tenantId, rs.getString(1));
+ assertEquals(B_VALUE, rs.getString(2));
+ assertFalse(rs.next());
+ conn.close();
+ }
+
+ @SuppressWarnings("unchecked")
+ @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
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ Connection upsertConn = DriverManager.getConnection(url, props);
+ String upsertStmt =
+ "upsert into " +
+ "ATABLE(" +
+ " ORGANIZATION_ID, " +
+ " ENTITY_ID, " +
+ " A_INTEGER) " +
+ "VALUES (?, ?, ?)";
+ upsertConn.setAutoCommit(true); // Test auto commit
+ // Insert all rows at ts
+ PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW1);
+ stmt.setInt(3, 6);
+ stmt.execute(); // 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);
+ upsertConn = DriverManager.getConnection(url, props);
+ upsertConn.setAutoCommit(true); // Test auto commit
+ // Insert all rows at ts
+ stmt = upsertConn.prepareStatement(upsertStmt);
+ stmt.setString(1, tenantId);
+ stmt.setString(2, ROW1);
+ stmt.setInt(3, 0);
+ stmt.execute(); // should commit too
+ upsertConn.close();
+
+ String query = "SELECT a_integer,b_string FROM atable WHERE organization_id=? and a_integer <= 5 limit 2";
+ props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2));
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ PreparedStatement statement = conn.prepareStatement(query);
+ statement.setString(1, tenantId);
+ ResultSet rs = statement.executeQuery();
+ List<List<Object>> expectedResultsA = Lists.newArrayList(
+ Arrays.<Object>asList(2, C_VALUE),
+ Arrays.<Object>asList( 3, E_VALUE));
+ List<List<Object>> expectedResultsB = Lists.newArrayList(
+ Arrays.<Object>asList( 5, C_VALUE),
+ Arrays.<Object>asList(4, B_VALUE));
+ // Since we're not ordering and we may be using a descending index, we don't
+ // know which rows we'll get back.
+ assertOneOfValuesEqualsResultSet(rs, expectedResultsA,expectedResultsB);
+ conn.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
index 3d0fa2c..965071f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java
@@ -151,7 +151,7 @@ public class NativeHBaseTypesIT extends BaseClientManagedTimeIT {
}
// Create Phoenix table after HBase table was created through the native APIs
// The timestamp of the table creation must be later than the timestamp of the data
- ensureTableCreated(getUrl(),HBASE_NATIVE,HBASE_NATIVE,null, ts+1);
+ ensureTableCreated(getUrl(),HBASE_NATIVE,HBASE_NATIVE,null, ts+1, null);
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 76627be..60a7cce 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
@@ -52,8 +52,8 @@ import com.google.common.primitives.Floats;
@RunWith(Parameterized.class)
public class NotQueryIT extends BaseQueryIT {
- public NotQueryIT(String indexDDL) {
- super(indexDDL);
+ public NotQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Parameters(name="NotQueryIT_{index}") // name is used by failsafe as file name in reports
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
index af5a905..408bf18 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
@@ -511,9 +511,9 @@ public class PercentileIT extends ParallelStatsDisabledIT {
Date date, Long ts) throws Exception {
String tableName = generateUniqueName();
if (ts == null) {
- ensureTableCreated(getUrl(), tableName, ATABLE_NAME, splits);
+ ensureTableCreated(getUrl(), tableName, ATABLE_NAME, splits, null);
} else {
- ensureTableCreated(getUrl(), tableName, ATABLE_NAME, splits, ts - 2);
+ ensureTableCreated(getUrl(), tableName, ATABLE_NAME, splits, ts - 2, null);
}
Properties props = new Properties();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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
index 73eb2a3..3805f21 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java
@@ -17,18 +17,13 @@
*/
package org.apache.phoenix.end2end;
-import static org.apache.phoenix.util.TestUtil.A_VALUE;
-import static org.apache.phoenix.util.TestUtil.B_VALUE;
-import static org.apache.phoenix.util.TestUtil.ROW4;
import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.Connection;
import java.sql.DriverManager;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;
import java.util.Properties;
@@ -44,8 +39,8 @@ import com.google.common.collect.Maps;
public class PointInTimeQueryIT extends BaseQueryIT {
- public PointInTimeQueryIT(String indexDDL) {
- super(indexDDL);
+ public PointInTimeQueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@BeforeClass
@@ -57,61 +52,6 @@ public class PointInTimeQueryIT 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);
- Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
- Connection upsertConn = DriverManager.getConnection(url, props);
- String upsertStmt =
- "upsert into " +
- "ATABLE(" +
- " ORGANIZATION_ID, " +
- " ENTITY_ID, " +
- " A_INTEGER) " +
- "VALUES (?, ?, ?)";
- upsertConn.setAutoCommit(true); // Test auto commit
- // Insert all rows at ts
- PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
- stmt.setString(1, tenantId);
- stmt.setString(2, ROW4);
- stmt.setInt(3, 5);
- stmt.execute(); // should commit too
-
- url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 15);
- Connection conn1 = DriverManager.getConnection(url, props);
- analyzeTable(conn1, "ATABLE");
- 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
- stmt = upsertConn.prepareStatement(upsertStmt);
- stmt.setString(1, tenantId);
- stmt.setString(2, ROW4);
- stmt.setInt(3, 9);
- stmt.execute(); // should commit too
- upsertConn.close();
-
- String query = "SELECT organization_id, a_string AS a FROM atable WHERE organization_id=? and a_integer = 5";
- props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
- Connection conn = DriverManager.getConnection(getUrl(), props);
- PreparedStatement statement = conn.prepareStatement(query);
- statement.setString(1, tenantId);
- ResultSet rs = statement.executeQuery();
- assertTrue(rs.next());
- assertEquals(tenantId, rs.getString(1));
- assertEquals(A_VALUE, rs.getString("a"));
- assertTrue(rs.next());
- assertEquals(tenantId, rs.getString(1));
- assertEquals(B_VALUE, rs.getString(2));
- assertFalse(rs.next());
- conn.close();
- }
-
- @Test
public void testPointInTimeSequence() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
index 17c854a..87b7af6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
@@ -89,7 +89,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT {
}
private static void initTable(byte[][] splits, long ts) throws Exception {
- ensureTableCreated(getUrl(), PRODUCT_METRICS_NAME, PRODUCT_METRICS_NAME,splits, ts-2);
+ ensureTableCreated(getUrl(), PRODUCT_METRICS_NAME, PRODUCT_METRICS_NAME,splits, ts-2, null);
}
private static void assertNoRows(Connection conn) throws SQLException {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
index ec9f32f..6b3778a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
@@ -655,7 +655,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testCreateDropTable() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
ensureTableCreated(getUrl(), BTABLE_NAME, BTABLE_NAME, ts-2);
ensureTableCreated(getUrl(), PTSDB_NAME, PTSDB_NAME, ts-2);
@@ -977,7 +977,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testAddKVColumnToExistingFamily() throws Throwable {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
@@ -1008,7 +1008,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testAddKVColumnToNewFamily() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
Connection conn1 = DriverManager.getConnection(getUrl(), props);
@@ -1034,7 +1034,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testAddPKColumn() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
@@ -1067,7 +1067,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testDropKVColumn() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
@@ -1107,7 +1107,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testDropPKColumn() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
@@ -1125,7 +1125,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
public void testDropAllKVCols() throws Exception {
ResultSet rs;
long ts = nextTimestamp();
- ensureTableCreated(getUrl(), MDTEST_NAME, MDTEST_NAME, null, ts);
+ ensureTableCreated(getUrl(), MDTEST_NAME, MDTEST_NAME, null, ts, null);
Properties props = new Properties();
@@ -1171,7 +1171,7 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
@Test
public void testNewerTableDisallowed() throws Exception {
long ts = nextTimestamp();
- ensureTableCreated(getUrl(), ATABLE_NAME, ATABLE_NAME, null, ts);
+ ensureTableCreated(getUrl(), ATABLE_NAME, ATABLE_NAME, null, ts, null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/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 d3bbe23..211b445 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
@@ -62,8 +62,8 @@ import org.junit.Test;
*/
public class QueryIT extends BaseQueryIT {
- public QueryIT(String indexDDL) {
- super(indexDDL);
+ public QueryIT(String indexDDL, boolean mutable, boolean columnEncoded) {
+ super(indexDDL, mutable, columnEncoded);
}
@Test
@@ -124,11 +124,6 @@ public class QueryIT extends BaseQueryIT {
}
@Test
- public void testEmptyStringValue() throws Exception {
- testNoStringValue("");
- }
-
- @Test
public void testToDateOnString() throws Exception { // TODO: test more conversion combinations
String query = "SELECT a_string FROM aTable WHERE organization_id=? and a_integer = 5";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
@@ -167,47 +162,6 @@ public class QueryIT extends BaseQueryIT {
}
}
- private void testNoStringValue(String value) throws Exception {
- 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
- // Insert all rows at ts
- PreparedStatement stmt = upsertConn.prepareStatement(
- "upsert into ATABLE VALUES (?, ?, ?)"); // without specifying columns
- stmt.setString(1, tenantId);
- stmt.setString(2, ROW5);
- stmt.setString(3, value);
- 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, "ATABLE");
- conn1.close();
-
- String query = "SELECT a_string, b_string FROM aTable 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);
- statement.setString(1, tenantId);
- ResultSet rs = statement.executeQuery();
- assertTrue (rs.next());
- assertEquals(null, rs.getString(1));
- assertTrue(rs.wasNull());
- assertEquals(C_VALUE, rs.getString("B_string"));
- assertFalse(rs.next());
- } finally {
- conn.close();
- }
- }
-
- @Test
- public void testNullStringValue() throws Exception {
- testNoStringValue(null);
- }
-
@Test
public void testDateInList() throws Exception {
String query = "SELECT entity_id FROM ATABLE WHERE a_date IN (?,?) AND a_integer < 4";
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java
index 1573533..8b320fa 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java
@@ -42,7 +42,7 @@ public class ReadIsolationLevelIT extends BaseClientManagedTimeIT {
protected static void initTableValues(long ts, byte[][] splits) throws Exception {
String tenantId = getOrganizationId();
- ensureTableCreated(getUrl(),ATABLE_NAME, ATABLE_NAME, splits, ts-2);
+ ensureTableCreated(getUrl(),ATABLE_NAME, ATABLE_NAME, splits, ts-2, null);
Properties props = new Properties();
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
http://git-wip-us.apache.org/repos/asf/phoenix/blob/e89337f8/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
index 861455e..b7d67f2 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
@@ -66,7 +66,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorInWhereWithEqualsExpression() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer) = (7, 5)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -91,7 +91,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorInWhereWithGreaterThanExpression() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer) >= (4, 4)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -117,7 +117,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorInWhereWithUnEqualNumberArgs() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer, y_integer) >= (7, 5)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -143,7 +143,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testBindVarsInRowValueConstructor() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer) = (?, ?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -170,7 +170,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorOnLHSAndLiteralExpressionOnRHS() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer) >= 7";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -194,7 +194,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorOnRHSLiteralExpressionOnLHS() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND 7 <= (a_integer, x_integer)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -218,7 +218,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorOnLHSBuiltInFunctionOperatingOnIntegerLiteralRHS() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer) >= to_number('7')";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -242,7 +242,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorOnRHSWithBuiltInFunctionOperatingOnIntegerLiteralOnLHS() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND to_number('7') <= (a_integer, x_integer)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -266,7 +266,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorOnLHSWithBuiltInFunctionOperatingOnColumnRefOnRHS() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts - 1, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts - 1, getUrl(), null);
String upsertQuery = "UPSERT INTO aTable(organization_id, entity_id, a_string) values (?, ?, ?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
@@ -332,7 +332,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRowValueConstructorOnRHSWithBuiltInFunctionOperatingOnColumnRefOnLHS() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts - 1, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts - 1, getUrl(), null);
String upsertQuery = "UPSERT INTO aTable(organization_id, entity_id, a_string) values (?, ?, ?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
@@ -654,7 +654,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRVCWithNonLeadingPkColsOfTypesIntegerAndString() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, a_string FROM aTable WHERE ?=organization_id AND (a_integer, a_string) <= (5, 'a')";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -680,7 +680,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRVCWithNonLeadingPkColsOfTypesTimeStampAndString() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String updateStmt =
"upsert into " +
"ATABLE(" +
@@ -724,7 +724,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testNestedRVCBasic() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
//all the three queries should return the same rows.
String[] queries = {"SELECT organization_id, entity_id, a_string FROM aTable WHERE ((organization_id, entity_id), a_string) >= ((?, ?), ?)",
"SELECT organization_id, entity_id, a_string FROM aTable WHERE (organization_id, entity_id, a_string) >= (?, ?, ?)",
@@ -762,7 +762,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRVCWithInListClausePossibleNullValues() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
//we have a row present in aTable where x_integer = 5 and y_integer = NULL which gets translated to 0 when retriving from HBase.
String query = "SELECT x_integer, y_integer FROM aTable WHERE ? = organization_id AND (x_integer, y_integer) IN ((5))";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
@@ -784,7 +784,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRVCWithInListClauseUsingSubsetOfPKColsInOrder() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
// Though we have a row present in aTable where organization_id = tenantId and x_integer = 5,
// we'd also need to have an entity_id that is null (which we don't have).
String query = "SELECT organization_id, entity_id FROM aTable WHERE (organization_id, entity_id) IN (('" + tenantId + "')) AND x_integer = 5";
@@ -814,7 +814,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
public void testRVCWithCeilAndFloorNeededForDecimal() throws Exception {
long ts = nextTimestamp();
String tenantId = getOrganizationId();
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts, getUrl(), null);
String query = "SELECT a_integer, x_integer FROM aTable WHERE ?=organization_id AND (a_integer, x_integer) < (8.6, 4.5) AND (a_integer, x_integer) > (6.8, 4)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2
@@ -841,7 +841,7 @@ public class RowValueConstructorIT extends BaseClientManagedTimeIT {
String tenantId = getOrganizationId();
Date dateUpserted = DateUtil.parseDate("2012-01-01 14:25:28");
dateUpserted = new Date(dateUpserted.getTime() + 660); // this makes the dateUpserted equivalent to 2012-01-01 14:25:28.660
- initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), dateUpserted, ts, getUrl());
+ initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), dateUpserted, ts, getUrl(), null);
String query = "SELECT a_integer, a_date FROM aTable WHERE ?=organization_id AND (a_integer, a_date) <= (9, ?) AND (a_integer, a_date) >= (6, ?)";
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2