Skip to content

Commit 592e530

Browse files
committed
use TableName
1 parent 6c16fc8 commit 592e530

6 files changed

Lines changed: 23 additions & 18 deletions

File tree

ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,13 +4081,13 @@ public List<Partition> dropPartitions(String dbName, String tableName,
40814081
exprs.add(dpe);
40824082
}
40834083
rps.setExprs(exprs);
4084-
return dropPartitions(getDefaultCatalog(conf), dbName, tableName, rps, dropOptions);
4084+
return dropPartitions(new TableName(getDefaultCatalog(conf), dbName, tableName), rps, dropOptions);
40854085
}
40864086

4087-
public List<Partition> dropPartitions(String catName, String dbName, String tableName,
4087+
public List<Partition> dropPartitions(TableName tableName,
40884088
RequestPartsSpec partsSpec, PartitionDropOptions dropOptions) throws HiveException {
40894089
try {
4090-
Table table = getTable(dbName, tableName);
4090+
Table table = getTable(tableName.getDb(), tableName.getTable());
40914091
if (!dropOptions.deleteData) {
40924092
AcidUtils.TableSnapshot snapshot = AcidUtils.getTableSnapshot(conf, table, true);
40934093
if (snapshot != null) {
@@ -4098,7 +4098,7 @@ public List<Partition> dropPartitions(String catName, String dbName, String tabl
40984098
dropOptions.setTxnId(txnId);
40994099
}
41004100
List<org.apache.hadoop.hive.metastore.api.Partition> partitions = getMSC().dropPartitions(
4101-
catName, dbName, tableName, partsSpec, dropOptions, null);
4101+
tableName, partsSpec, dropOptions, null);
41024102
return convertFromMetastore(table, partitions);
41034103
} catch (NoSuchObjectException e) {
41044104
throw new HiveException("Partition or table doesn't exist.", e);

ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,11 +1562,11 @@ public boolean dropPartition(String catName, String dbName, String tableName, St
15621562
}
15631563

15641564
@Override
1565-
public List<Partition> dropPartitions(String catName, String dbName, String tblName,
1565+
public List<Partition> dropPartitions(TableName tableName,
15661566
RequestPartsSpec partsSpec, PartitionDropOptions options, EnvironmentContext context)
15671567
throws TException {
1568-
if (isDefaultCatalog(catName)) {
1569-
Table table = getTempTable(dbName, tblName);
1568+
if (isDefaultCatalog(tableName.getCat())) {
1569+
Table table = getTempTable(tableName.getDb(), tableName.getTable());
15701570
if (table != null) {
15711571
TempTable tt = getPartitionedTempTable(table);
15721572
List<List<String>> partValues = new ArrayList<>();
@@ -1602,7 +1602,7 @@ public List<Partition> dropPartitions(String catName, String dbName, String tblN
16021602
}
16031603
}
16041604

1605-
return delegate.dropPartitions(catName, dbName, tblName, partsSpec, options, context);
1605+
return delegate.dropPartitions(tableName, partsSpec, options, context);
16061606
}
16071607

16081608
@Override

standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ List<Partition> dropPartitions(String catName, String dbName, String tblName,
20922092
List<Pair<Integer, byte[]>> partExprs, PartitionDropOptions options, EnvironmentContext context)
20932093
throws NoSuchObjectException, MetaException, TException;
20942094

2095-
List<Partition> dropPartitions(String catName, String dbName, String tblName,
2095+
List<Partition> dropPartitions(TableName tableName,
20962096
RequestPartsSpec partsSpec, PartitionDropOptions options, EnvironmentContext context)
20972097
throws NoSuchObjectException, MetaException, TException;
20982098

standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/client/HookEnabledMetaStoreClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.apache.commons.lang3.tuple.Pair;
2222
import org.apache.hadoop.conf.Configuration;
23+
import org.apache.hadoop.hive.common.TableName;
2324
import org.apache.hadoop.hive.metastore.DefaultHiveMetaHook;
2425
import org.apache.hadoop.hive.metastore.HiveMetaHook;
2526
import org.apache.hadoop.hive.metastore.HiveMetaHookLoader;
@@ -327,18 +328,18 @@ public List<Partition> dropPartitions(String catName, String dbName, String tblN
327328
}
328329

329330
@Override
330-
public List<Partition> dropPartitions(String catName, String dbName, String tblName,
331+
public List<Partition> dropPartitions(TableName tableName,
331332
RequestPartsSpec partsSpec, PartitionDropOptions options, EnvironmentContext context)
332333
throws TException {
333-
Table table = delegate.getTable(catName, dbName, tblName);
334+
Table table = delegate.getTable(tableName.getCat(), tableName.getDb(), tableName.getTable());
334335
HiveMetaHook hook = getHook(table);
335336
if (hook != null) {
336337
if (context == null) {
337338
context = new EnvironmentContext();
338339
}
339340
hook.preDropPartitions(table, context, partsSpec);
340341
}
341-
return delegate.dropPartitions(catName, dbName, tblName, partsSpec, options, context);
342+
return delegate.dropPartitions(tableName, partsSpec, options, context);
342343
}
343344

344345
@Override

standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/client/MetaStoreClientWrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
package org.apache.hadoop.hive.metastore.client;
2020

21-
import org.apache.commons.lang3.tuple.Pair;
2221
import org.apache.hadoop.conf.Configuration;
22+
import org.apache.hadoop.hive.common.TableName;
2323
import org.apache.hadoop.hive.common.ValidTxnList;
2424
import org.apache.hadoop.hive.common.ValidWriteIdList;
2525
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
@@ -504,10 +504,10 @@ public boolean dropPartition(String catName, String db_name, String tbl_name, Li
504504
}
505505

506506
@Override
507-
public List<Partition> dropPartitions(String catName, String dbName, String tblName,
507+
public List<Partition> dropPartitions(TableName tableName,
508508
RequestPartsSpec partsSpec, PartitionDropOptions options, EnvironmentContext context)
509509
throws NoSuchObjectException, MetaException, TException {
510-
return delegate.dropPartitions(catName, dbName, tblName, partsSpec, options, context);
510+
return delegate.dropPartitions(tableName, partsSpec, options, context);
511511
}
512512

513513
@Override

standalone-metastore/metastore-client/src/main/java/org/apache/hadoop/hive/metastore/client/ThriftHiveMetaStoreClient.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.hadoop.classification.InterfaceAudience;
2626
import org.apache.hadoop.conf.Configuration;
2727
import org.apache.hadoop.hive.common.StatsSetupConst;
28+
import org.apache.hadoop.hive.common.TableName;
2829
import org.apache.hadoop.hive.common.ValidTxnList;
2930
import org.apache.hadoop.hive.common.ValidWriteIdList;
3031
import org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl;
@@ -1587,15 +1588,18 @@ public boolean dropPartition(String catName, String db_name, String tbl_name,
15871588
}
15881589

15891590
@Override
1590-
public List<Partition> dropPartitions(String catName, String dbName, String tblName,
1591+
public List<Partition> dropPartitions(TableName tableName,
15911592
RequestPartsSpec partsSpec, PartitionDropOptions options, EnvironmentContext context)
15921593
throws NoSuchObjectException, MetaException, TException {
1593-
DropPartitionsRequest req = new DropPartitionsRequest(dbName, tblName, partsSpec);
1594-
req.setCatName(catName);
1594+
DropPartitionsRequest req = new DropPartitionsRequest(tableName.getDb(), tableName.getTable(), partsSpec);
1595+
req.setCatName(tableName.getCat());
15951596
req.setDeleteData(options.deleteData);
15961597
req.setNeedResult(options.returnResults);
15971598
req.setIfExists(options.ifExists);
15981599

1600+
if (context == null) {
1601+
context = new EnvironmentContext();
1602+
}
15991603
if (options.purgeData) {
16001604
LOG.info("Dropped partitions will be purged!");
16011605
context.putToProperties("ifPurge", "true");

0 commit comments

Comments
 (0)