org.apache.hadoop.hive.metastore.api.Table.deepCopy()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.apache.hadoop.hive.metastore.api.Table.deepCopy()方法的一些代码示例,展示了Table.deepCopy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.deepCopy()方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Table
类名称:Table
方法名:deepCopy

Table.deepCopy介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@Override
public synchronized void updateTableStatistics(String databaseName, String tableName, Function<PartitionStatistics, PartitionStatistics> update)
{
  PartitionStatistics currentStatistics = getTableStatistics(databaseName, tableName);
  PartitionStatistics updatedStatistics = update.apply(currentStatistics);
  Table originalTable = getTable(databaseName, tableName)
      .orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));
  Table modifiedTable = originalTable.deepCopy();
  HiveBasicStatistics basicStatistics = updatedStatistics.getBasicStatistics();
  modifiedTable.setParameters(updateStatisticsParameters(modifiedTable.getParameters(), basicStatistics));
  alterTable(databaseName, tableName, modifiedTable);
  com.facebook.presto.hive.metastore.Table table = fromMetastoreApiTable(modifiedTable);
  OptionalLong rowCount = basicStatistics.getRowCount();
  List<ColumnStatisticsObj> metastoreColumnStatistics = updatedStatistics.getColumnStatistics().entrySet().stream()
      .map(entry -> createMetastoreColumnStatistics(entry.getKey(), table.getColumn(entry.getKey()).get().getType(), entry.getValue(), rowCount))
      .collect(toImmutableList());
  if (!metastoreColumnStatistics.isEmpty()) {
    setTableColumnStatistics(databaseName, tableName, metastoreColumnStatistics);
  }
  Set<String> removedColumnStatistics = difference(currentStatistics.getColumnStatistics().keySet(), updatedStatistics.getColumnStatistics().keySet());
  removedColumnStatistics.forEach(column -> deleteTableColumnStatistics(databaseName, tableName, column));
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableNoSuchDatabase() throws Exception {
 Table originalTable = testTables[2];
 Table newTable = originalTable.deepCopy();
 client.alter_table("no_such_database", originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableNoSuchTable() throws Exception {
 Table originalTable = testTables[2];
 Table newTable = originalTable.deepCopy();
 client.alter_table(originalTable.getDbName(), "no_such_table_name", newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableNoSuchTableInThisDatabase() throws Exception {
 Table originalTable = testTables[2];
 Table newTable = originalTable.deepCopy();
 client.alter_table(OTHER_DATABASE, originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void alterTableBogusCatalog() throws TException {
 Table t = testTables[0].deepCopy();
 t.getParameters().put("a", "b");
 client.alter_table("nosuch", t.getDbName(), t.getTableName(), t);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableInvalidStorageDescriptorRemovePartitionColumn() throws Exception {
 Table originalTable = partitionedTable;
 Table newTable = originalTable.deepCopy();
 newTable.getPartitionKeys().remove(0);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test
public void testAlterTableNullDatabase() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 try {
  client.alter_table(null, originalTable.getTableName(), newTable);
  Assert.fail("Expected exception");
 } catch (MetaException | TProtocolException ex) {
 }
}

代码示例来源:origin: apache/hive

@Test
public void testAlterTableNullTableName() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 try {
  client.alter_table(originalTable.getDbName(), null, newTable);
  Assert.fail("Expected exception");
 } catch (MetaException | TProtocolException ex) {
  // Expected.
 }
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableInvalidStorageDescriptorAlterPartitionColumnName() throws Exception {
 Table originalTable = partitionedTable;
 Table newTable = originalTable.deepCopy();
 newTable.getPartitionKeys().get(0).setName("altered_name");
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableInvalidTableNameInNew() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.setTableName("test_table;");
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableEmptyTableNameInNew() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.setTableName("");
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableInvalidStorageDescriptorInvalidColumnType() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.getSd().getCols().get(0).setType("xyz");
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterTableNullDatabaseInNew() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.setDbName(null);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterTableInvalidStorageDescriptorNullColumnType() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.getSd().getCols().get(0).setType(null);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterTableNullStorageDescriptorInNew() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.setSd(null);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterTableInvalidStorageDescriptorNullSerdeInfo() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.getSd().setSerdeInfo(null);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterTableInvalidStorageDescriptorNullLocation() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.getSd().setLocation(null);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test(expected = InvalidOperationException.class)
public void testAlterTableInvalidStorageDescriptorAddPartitionColumns() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.addToPartitionKeys(new FieldSchema("new_part", "int", "comment"));
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

代码示例来源:origin: apache/hive

@Test
public void testAlterTableNullTableNameInNew() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.setTableName(null);
 try {
  client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
  Assert.fail("Expected exception");
 } catch (MetaException | TProtocolException ex) {
  // Expected.
 }
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterTableInvalidStorageDescriptorNullCols() throws Exception {
 Table originalTable = testTables[0];
 Table newTable = originalTable.deepCopy();
 newTable.getSd().setCols(null);
 client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
}

相关文章

Table类方法