You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2018/06/27 02:05:43 UTC
[10/13] hive git commit: HIVE-19532 : fix tests for master-txnstats
branch (Sergey Shelukhin)
HIVE-19532 : fix tests for master-txnstats branch (Sergey Shelukhin)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/bdc256ed
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/bdc256ed
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/bdc256ed
Branch: refs/heads/master-txnstats
Commit: bdc256edeff716b655edc0604b8d0e9cd9fe8597
Parents: 3c21861
Author: sergey <se...@apache.org>
Authored: Tue Jun 26 18:12:41 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Tue Jun 26 18:12:41 2018 -0700
----------------------------------------------------------------------
.../hadoop/hive/ql/metadata/TestHive.java | 7 ++++++
.../hive/metastore/HiveMetaStoreClient.java | 2 +-
.../hadoop/hive/metastore/IMetaStoreClient.java | 2 +-
.../hadoop/hive/metastore/ObjectStore.java | 4 +--
.../metastore/client/TestAlterPartitions.java | 26 ++++++++++++++------
5 files changed, 30 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/bdc256ed/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
index a24b642..930282d 100755
--- a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
@@ -324,6 +324,13 @@ public class TestHive extends TestCase {
tbl.setCreateTime(ft.getTTable().getCreateTime());
tbl.getParameters().put(hive_metastoreConstants.DDL_TIME,
ft.getParameters().get(hive_metastoreConstants.DDL_TIME));
+ // Txn stuff set by metastore
+ if (tbl.getTTable().isSetTxnId()) {
+ ft.getTTable().setTxnId(tbl.getTTable().getTxnId());
+ }
+ if (tbl.getTTable().isSetValidWriteIdList()) {
+ ft.getTTable().setValidWriteIdList(tbl.getTTable().getValidWriteIdList());
+ }
assertTrue("Tables doesn't match: " + tableName + " (" + ft.getTTable()
+ "; " + tbl.getTTable() + ")", ft.getTTable().equals(tbl.getTTable()));
assertEquals("SerializationLib is not set correctly", tbl
http://git-wip-us.apache.org/repos/asf/hive/blob/bdc256ed/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 626e103..1e50ba7 100644
--- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -1886,7 +1886,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
public void alter_partitions(String dbName, String tblName, List<Partition> newParts)
throws TException {
alter_partitions(
- getDefaultCatalog(conf), dbName, tblName, newParts, null, -1, null);
+ getDefaultCatalog(conf), dbName, tblName, newParts, new EnvironmentContext(), -1, null);
}
@Override
http://git-wip-us.apache.org/repos/asf/hive/blob/bdc256ed/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
index c4cd8b4..8bc3df5 100644
--- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
@@ -2155,7 +2155,7 @@ public interface IMetaStoreClient {
default void alter_partitions(String catName, String dbName, String tblName,
List<Partition> newParts)
throws InvalidOperationException, MetaException, TException {
- alter_partitions(catName, dbName, tblName, newParts, null,-1, null);
+ alter_partitions(catName, dbName, tblName, newParts, new EnvironmentContext(), -1, null);
}
/**
http://git-wip-us.apache.org/repos/asf/hive/blob/bdc256ed/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index 9266879..2c3554e 100644
--- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -2381,6 +2381,7 @@ public class ObjectStore implements RawStore, Configurable {
boolean commited = false;
try {
+ openTransaction();
String catName = part.isSetCatName() ? part.getCatName() : getDefaultCatalog(conf);
MTable table = this.getMTable(catName, part.getDbName(), part.getTableName());
List<MTablePrivilege> tabGrants = null;
@@ -2390,7 +2391,6 @@ public class ObjectStore implements RawStore, Configurable {
tabColumnGrants = this.listTableAllColumnGrants(
catName, part.getDbName(), part.getTableName());
}
- openTransaction();
MPartition mpart = convertToMPart(part, table, true);
pm.makePersistent(mpart);
@@ -4202,7 +4202,7 @@ public class ObjectStore implements RawStore, Configurable {
catName = normalizeIdentifier(catName);
name = normalizeIdentifier(name);
dbname = normalizeIdentifier(dbname);
- MTable table = this.getMTable(catName, dbname, name);
+ MTable table = this.getMTable(newPart.getCatName(), newPart.getDbName(), newPart.getTableName());
MPartition oldp = getMPartition(catName, dbname, name, part_vals);
MPartition newp = convertToMPart(newPart, table, false);
MColumnDescriptor oldCD = null;
http://git-wip-us.apache.org/repos/asf/hive/blob/bdc256ed/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
index f19b505..0a62ac1 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.hive.metastore.client;
+import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -41,6 +42,7 @@ import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder;
import org.apache.hadoop.hive.metastore.client.builder.TableBuilder;
import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.transport.TTransportException;
import com.google.common.collect.Lists;
@@ -692,11 +694,16 @@ public class TestAlterPartitions extends MetaStoreClientTest {
client.alter_partitions(DB_NAME, "", Lists.newArrayList(part));
}
- @Test(expected = MetaException.class)
+ @Test
public void testAlterPartitionsNullTblName() throws Exception {
createTable4PartColsParts(client);
Partition part = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0);
- client.alter_partitions(DB_NAME, null, Lists.newArrayList(part));
+ try {
+ client.alter_partitions(DB_NAME, null, Lists.newArrayList(part));
+ Assert.fail("didn't throw");
+ } catch (TProtocolException | MetaException e) {
+ // By design
+ }
}
@Test(expected = NullPointerException.class)
@@ -720,7 +727,7 @@ public class TestAlterPartitions extends MetaStoreClientTest {
Partition part = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0);
client.alter_partitions(DB_NAME, TABLE_NAME, null);
fail("Should have thrown exception");
- } catch (NullPointerException | TTransportException e) {
+ } catch (NullPointerException | TTransportException | TProtocolException e) {
//TODO: should not throw different exceptions for different HMS deployment types
}
}
@@ -786,7 +793,7 @@ public class TestAlterPartitions extends MetaStoreClientTest {
assertPartitionsHaveCorrectValues(newParts, testValues);
client.alter_partitions(DB_NAME, TABLE_NAME, newParts, new EnvironmentContext());
- client.alter_partitions(DB_NAME, TABLE_NAME, newParts, null);
+ client.alter_partitions(DB_NAME, TABLE_NAME, newParts);
for (int i = 0; i < testValues.size(); ++i) {
assertPartitionChanged(oldParts.get(i), testValues.get(i), PARTCOL_SCHEMA);
@@ -860,11 +867,16 @@ public class TestAlterPartitions extends MetaStoreClientTest {
client.alter_partitions(DB_NAME, "", Lists.newArrayList(part), new EnvironmentContext());
}
- @Test(expected = MetaException.class)
+ @Test
public void testAlterPartitionsWithEnvironmentCtxNullTblName() throws Exception {
createTable4PartColsParts(client);
Partition part = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0);
- client.alter_partitions(DB_NAME, null, Lists.newArrayList(part), new EnvironmentContext());
+ try {
+ client.alter_partitions(DB_NAME, null, Lists.newArrayList(part), new EnvironmentContext());
+ Assert.fail("didn't throw");
+ } catch (MetaException | TProtocolException ex) {
+ // By design.
+ }
}
@Test(expected = NullPointerException.class)
@@ -890,7 +902,7 @@ public class TestAlterPartitions extends MetaStoreClientTest {
Partition part = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0);
client.alter_partitions(DB_NAME, TABLE_NAME, null, new EnvironmentContext());
fail("Should have thrown exception");
- } catch (NullPointerException | TTransportException e) {
+ } catch (NullPointerException | TTransportException | TProtocolException e) {
//TODO: should not throw different exceptions for different HMS deployment types
}
}