本文整理汇总了Java中org.apache.hadoop.hive.metastore.api.InvalidOperationException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidOperationException类的具体用法?Java InvalidOperationException怎么用?Java InvalidOperationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidOperationException类属于org.apache.hadoop.hive.metastore.api包,在下文中一共展示了InvalidOperationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorizeCreateTable
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
private void authorizeCreateTable(PreCreateTableEvent context)
throws InvalidOperationException, MetaException {
HierarcyBuilder inputBuilder = new HierarcyBuilder();
inputBuilder.addDbToOutput(getAuthServer(), context.getTable().getDbName());
HierarcyBuilder outputBuilder = new HierarcyBuilder();
outputBuilder.addDbToOutput(getAuthServer(), context.getTable().getDbName());
if (!StringUtils.isEmpty(context.getTable().getSd().getLocation())) {
String uriPath;
try {
uriPath = PathUtils.parseDFSURI(warehouseDir,
getSdLocation(context.getTable().getSd()));
} catch(URISyntaxException e) {
throw new MetaException(e.getMessage());
}
inputBuilder.addUriToOutput(getAuthServer(), uriPath, warehouseDir);
}
authorizeMetastoreAccess(HiveOperation.CREATETABLE, inputBuilder.build(),
outputBuilder.build());
}
示例2: throwExceptionIfIncompatibleColTypeChange
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
static void throwExceptionIfIncompatibleColTypeChange(
List<FieldSchema> oldCols, List<FieldSchema> newCols)
throws InvalidOperationException {
List<String> incompatibleCols = new ArrayList<String>();
int maxCols = Math.min(oldCols.size(), newCols.size());
for (int i = 0; i < maxCols; i++) {
if (!areColTypesCompatible(oldCols.get(i).getType(), newCols.get(i).getType())) {
incompatibleCols.add(newCols.get(i).getName());
}
}
if (!incompatibleCols.isEmpty()) {
throw new InvalidOperationException(
"The following columns have types incompatible with the existing " +
"columns in their respective positions :\n" +
Joiner.on(',').join(incompatibleCols)
);
}
}
示例3: throwExceptionIfColAddedDeletedInMiddle
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
static void throwExceptionIfColAddedDeletedInMiddle(
List<FieldSchema> oldCols, List<FieldSchema> newCols)
throws InvalidOperationException {
if (oldCols.size() == newCols.size()) {
// Nothing to do since there were no columns added or removed.
return;
}
int maxCols = Math.min(oldCols.size(), newCols.size());
for (int i = 0; i < maxCols; i++) {
String oldColName = oldCols.get(i).getName();
String newColName = newCols.get(i).getName();
if (!oldColName.equals(newColName)) {
throw new InvalidOperationException(
"You can only add/remove columns from the end of a table." +
"If that is indeed what you are doing here, you are seeing this " +
"error because you are renaming a column at the same time. " +
"Please do the rename in a separate DDL operation." +
"Problematic columns: " +
"Old Table: " + oldColName + ", " +
"New Table: " + newColName
);
}
}
}
示例4: drop_database
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Test
public void drop_database() throws NoSuchObjectException, InvalidOperationException, MetaException, TException {
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
handler.drop_database(DB_P, false, false);
verify(primaryMapping).checkWritePermissions(DB_P);
verify(primaryClient).drop_database("inbound", false, false);
}
示例5: get_table_objects_by_name
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Test
public void get_table_objects_by_name()
throws MetaException, InvalidOperationException, UnknownDBException, TException {
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
Table table = new Table();
Table outbound = new Table();
when(primaryClient.get_table_objects_by_name("inbound", Lists.newArrayList("table")))
.thenReturn(Lists.newArrayList(table));
when(primaryMapping.transformOutboundTable(table)).thenReturn(outbound);
List<Table> result = handler.get_table_objects_by_name(DB_P, Lists.newArrayList("table"));
List<Table> expected = Lists.newArrayList(outbound);
assertThat(result, is(expected));
}
示例6: get_table_names_by_filter
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Test
public void get_table_names_by_filter()
throws MetaException, InvalidOperationException, UnknownDBException, TException {
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
List<String> tables = Lists.newArrayList("table1");
when(primaryClient.get_table_names_by_filter("inbound", "*", (short) 2)).thenReturn(tables);
List<String> result = handler.get_table_names_by_filter(DB_P, "*", (short) 2);
assertThat(result, is(tables));
}
示例7: alter_table
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Test
public void alter_table() throws InvalidOperationException, MetaException, TException {
Table table = new Table();
table.setDbName(DB_P);
Table inbound = new Table();
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
when(primaryMapping.transformInboundTable(table)).thenReturn(inbound);
handler.alter_table(DB_P, "table", table);
verify(primaryMapping, times(2)).checkWritePermissions(DB_P);
verify(primaryClient).alter_table("inbound", "table", inbound);
}
示例8: alter_table_with_environment_context
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Test
public void alter_table_with_environment_context() throws InvalidOperationException, MetaException, TException {
EnvironmentContext environmentContext = new EnvironmentContext();
Table table = new Table();
table.setDbName(DB_P);
Table inbound = new Table();
when(primaryMapping.transformInboundDatabaseName(DB_P)).thenReturn("inbound");
when(primaryMapping.transformInboundTable(table)).thenReturn(inbound);
handler.alter_table_with_environment_context(DB_P, "table", table, environmentContext);
verify(primaryMapping, times(2)).checkWritePermissions(DB_P);
verify(primaryClient).alter_table_with_environment_context("inbound", "table", inbound, environmentContext);
}
示例9: get_table_objects_by_name_req
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Test
public void get_table_objects_by_name_req()
throws MetaException, InvalidOperationException, UnknownDBException, TException {
Table table0 = new Table();
table0.setDbName(DB_P);
table0.setTableName("table0");
Table table1 = new Table();
table1.setDbName(DB_P);
table1.setTableName("table1");
GetTablesRequest request = new GetTablesRequest(DB_P);
request.setTblNames(Arrays.asList(table0.getTableName(), table1.getTableName()));
GetTablesResult response = new GetTablesResult(Arrays.asList(table0, table1));
when(primaryClient.get_table_objects_by_name_req(request)).thenReturn(response);
when(primaryMapping.transformInboundGetTablesRequest(request)).thenReturn(request);
when(primaryMapping.transformOutboundGetTablesResult(response)).thenReturn(response);
GetTablesResult result = handler.get_table_objects_by_name_req(request);
assertThat(result.getTables().size(), is(2));
assertThat(result.getTables().get(0).getDbName(), is(DB_P));
assertThat(result.getTables().get(0).getTableName(), is("table0"));
assertThat(result.getTables().get(1).getDbName(), is(DB_P));
assertThat(result.getTables().get(1).getTableName(), is("table1"));
}
示例10: updatePartitions
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
public void updatePartitions(String factOrDimtableName, String storageName,
Map<UpdatePeriod, List<Partition>> partitions) throws HiveException, InvalidOperationException, LensException {
for (Map.Entry entry : partitions.entrySet()) {
List<Partition> partitionsToAlter = Lists.newArrayList();
partitionsToAlter.addAll((List<Partition>) entry.getValue());
String storageTableName = getStorageTableName(factOrDimtableName, storageName, (UpdatePeriod) entry.getKey());
partitionsToAlter.addAll(
getAllLatestPartsEquivalentTo(factOrDimtableName, storageTableName, (List<Partition>) entry.getValue()));
getStorage(storageName).updatePartitions(storageTableName, getClient(), factOrDimtableName, partitionsToAlter);
}
}
示例11: alterHiveTable
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
public void alterHiveTable(String table, Table hiveTable) throws HiveException, LensException {
try {
getClient().alterTable(table, hiveTable, null);
} catch (InvalidOperationException e) {
throw new HiveException(e);
}
if (enableCaching) {
// refresh the table in cache
refreshTable(table);
}
}
示例12: updatePartitions
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
/**
* Update existing partitions
* @param client hive client instance
* @param fact fact name
* @param partitions partitions to be updated
* @throws InvalidOperationException
* @throws HiveException
*/
public void updatePartitions(String storageTable, Hive client, String fact, List<Partition> partitions)
throws InvalidOperationException, HiveException {
boolean success = false;
try {
client.alterPartitions(storageTable, partitions, null);
success = true;
} finally {
if (success) {
commitUpdatePartition(partitions);
} else {
rollbackUpdatePartition(partitions);
}
}
}
示例13: listTableNamesByFilter
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
@Override
public List<String> listTableNamesByFilter(String dbName, String filter,
short maxTables) throws InvalidOperationException, UnknownDBException,
TException {
return filterTables(dbName,
super.listTableNamesByFilter(dbName, filter, maxTables));
}
示例14: onEvent
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
/**
* Main listener callback which is the entry point for Sentry
*/
@Override
public void onEvent(PreEventContext context) throws MetaException,
NoSuchObjectException, InvalidOperationException {
if (!needsAuthorization(getUserName())) {
return;
}
switch (context.getEventType()) {
case CREATE_TABLE:
authorizeCreateTable((PreCreateTableEvent) context);
break;
case DROP_TABLE:
authorizeDropTable((PreDropTableEvent) context);
break;
case ALTER_TABLE:
authorizeAlterTable((PreAlterTableEvent) context);
break;
case ADD_PARTITION:
authorizeAddPartition((PreAddPartitionEvent) context);
break;
case DROP_PARTITION:
authorizeDropPartition((PreDropPartitionEvent) context);
break;
case ALTER_PARTITION:
authorizeAlterPartition((PreAlterPartitionEvent) context);
break;
case CREATE_DATABASE:
authorizeCreateDatabase();
break;
case DROP_DATABASE:
authorizeDropDatabase((PreDropDatabaseEvent) context);
break;
case LOAD_PARTITION_DONE:
// noop for now
break;
default:
break;
}
}
示例15: authorizeDropDatabase
import org.apache.hadoop.hive.metastore.api.InvalidOperationException; //导入依赖的package包/类
private void authorizeDropDatabase(PreDropDatabaseEvent context)
throws InvalidOperationException, MetaException {
authorizeMetastoreAccess(HiveOperation.DROPDATABASE,
new HierarcyBuilder()
.addDbToOutput(getAuthServer(),
context.getDatabase().getName()).build(),
new HierarcyBuilder().addDbToOutput(getAuthServer(),
context.getDatabase().getName()).build());
}