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 2015/04/21 02:28:22 UTC
phoenix git commit: Added testDropColumn using timestamps
Repository: phoenix
Updated Branches:
refs/heads/txn 4906b8b2b -> 42a1ffc7f
Added testDropColumn using timestamps
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/42a1ffc7
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/42a1ffc7
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/42a1ffc7
Branch: refs/heads/txn
Commit: 42a1ffc7f4496a44b76023391c12745f9cae24a5
Parents: 4906b8b
Author: Thomas D'Silva <tw...@gmail.com>
Authored: Mon Apr 20 17:17:19 2015 -0700
Committer: Thomas D'Silva <tw...@gmail.com>
Committed: Mon Apr 20 17:17:24 2015 -0700
----------------------------------------------------------------------
.../phoenix/transactions/TransactionIT.java | 36 +--------
.../transactions/TxPointInTimeQueryIT.java | 78 ++++++++++++++++++++
.../java/org/apache/phoenix/query/BaseTest.java | 14 ++--
3 files changed, 90 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/42a1ffc7/phoenix-core/src/it/java/org/apache/phoenix/transactions/TransactionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/transactions/TransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/transactions/TransactionIT.java
index 8babaae..6530ef6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/transactions/TransactionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/transactions/TransactionIT.java
@@ -25,8 +25,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
-import co.cask.tephra.TxConstants;
-
import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
import org.apache.phoenix.end2end.Shadower;
import org.apache.phoenix.exception.SQLExceptionCode;
@@ -38,6 +36,8 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import co.cask.tephra.TxConstants;
+
import com.google.common.collect.Maps;
public class TransactionIT extends BaseHBaseManagedTimeIT {
@@ -46,33 +46,7 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
@Before
public void setUp() throws SQLException {
- Connection conn = DriverManager.getConnection(getUrl());
- try {
- conn.createStatement().execute(
- "create table "+ FULL_TABLE_NAME + "("
- + " varchar_pk VARCHAR NOT NULL, "
- + " char_pk CHAR(6) NOT NULL, "
- + " int_pk INTEGER NOT NULL, "
- + " long_pk BIGINT NOT NULL, "
- + " decimal_pk DECIMAL(31, 10) NOT NULL, "
- + " date_pk DATE NOT NULL, "
- + " a.varchar_col1 VARCHAR, "
- + " a.char_col1 CHAR(10), "
- + " a.int_col1 INTEGER, "
- + " a.long_col1 BIGINT, "
- + " a.decimal_col1 DECIMAL(31, 10), "
- + " a.date1 DATE, "
- + " b.varchar_col2 VARCHAR, "
- + " b.char_col2 CHAR(10), "
- + " b.int_col2 INTEGER, "
- + " b.long_col2 BIGINT, "
- + " b.decimal_col2 DECIMAL(31, 10), "
- + " b.date2 DATE "
- + " CONSTRAINT pk PRIMARY KEY (varchar_pk, char_pk, int_pk, long_pk DESC, decimal_pk, date_pk)) "
- + "TRANSACTIONAL=true");
- } finally {
- conn.close();
- }
+ ensureTableCreated(getUrl(), TRANSACTIONAL_DATA_TABLE);
}
@BeforeClass
@@ -289,7 +263,5 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
conn1.close();
}
}
-
-
-
+
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/42a1ffc7/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
new file mode 100644
index 0000000..2a468b3
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
@@ -0,0 +1,78 @@
+/*
+ * 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.transactions;
+
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.junit.Assert.assertFalse;
+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.end2end.BaseClientManagedTimeIT;
+import org.apache.phoenix.schema.ColumnNotFoundException;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TxPointInTimeQueryIT extends BaseClientManagedTimeIT {
+
+ protected long ts;
+
+ @Before
+ public void initTable() throws Exception {
+ ts = nextTimestamp();
+ }
+
+ @Test
+ public void testDropColumn() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+ try {
+ conn.createStatement()
+ .execute(
+ "CREATE TABLE t (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR) TRANSACTIONAL=true");
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
+ conn = DriverManager.getConnection(getUrl(), props);
+ // drop a column
+ conn.createStatement().execute("ALTER TABLE t DROP COLUMN v1");
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 11));
+ conn = DriverManager.getConnection(getUrl(), props);
+ String selectQuery = "SELECT v1 FROM t";
+ try {
+ conn.createStatement().executeQuery(selectQuery);
+ fail();
+ } catch (ColumnNotFoundException e) {
+ }
+
+ props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
+ conn = DriverManager.getConnection(getUrl(), props);
+ ResultSet rs = conn.createStatement().executeQuery(selectQuery);
+ assertFalse(rs.next());
+ } finally {
+ conn.close();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/42a1ffc7/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index 4ab438b..ed8c29b 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -81,6 +81,7 @@ import static org.apache.phoenix.util.TestUtil.STABLE_NAME;
import static org.apache.phoenix.util.TestUtil.TABLE_WITH_ARRAY;
import static org.apache.phoenix.util.TestUtil.TABLE_WITH_SALTING;
import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.apache.phoenix.util.TestUtil.TRANSACTIONAL_DATA_TABLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -110,12 +111,6 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
-import co.cask.tephra.TransactionManager;
-import co.cask.tephra.TxConstants;
-import co.cask.tephra.distributed.TransactionService;
-import co.cask.tephra.metrics.TxMetricsCollector;
-import co.cask.tephra.persist.InMemoryTransactionStateStorage;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -156,6 +151,12 @@ import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import co.cask.tephra.TransactionManager;
+import co.cask.tephra.TxConstants;
+import co.cask.tephra.distributed.TransactionService;
+import co.cask.tephra.metrics.TxMetricsCollector;
+import co.cask.tephra.persist.InMemoryTransactionStateStorage;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -417,6 +418,7 @@ public abstract class BaseTest {
" kv bigint)\n");
builder.put(INDEX_DATA_TABLE, "create table " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + INDEX_DATA_TABLE + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
builder.put(MUTABLE_INDEX_DATA_TABLE, "create table " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + MUTABLE_INDEX_DATA_TABLE + TEST_TABLE_SCHEMA);
+ builder.put(TRANSACTIONAL_DATA_TABLE, "create table " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + TRANSACTIONAL_DATA_TABLE + TEST_TABLE_SCHEMA + "TRANSACTIONAL=true");
builder.put("SumDoubleTest","create table SumDoubleTest" +
" (id varchar not null primary key, d DOUBLE, f FLOAT, ud UNSIGNED_DOUBLE, uf UNSIGNED_FLOAT, i integer, de decimal)");
builder.put(JOIN_ORDER_TABLE_FULL_NAME, "create table " + JOIN_ORDER_TABLE_FULL_NAME +