本文整理了Java中org.apache.hadoop.hive.metastore.api.Table.setCatName()
方法的一些代码示例,展示了Table.setCatName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.setCatName()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Table
类名称:Table
方法名:setCatName
暂无
代码示例来源:origin: apache/hive
private Table createTestTbl(String dbName, String tblName, String tblOwner,
List<FieldSchema> cols, List<FieldSchema> ptnCols) {
String serdeLocation = "file:/tmp";
Map<String, String> serdeParams = new HashMap<>();
Map<String, String> tblParams = new HashMap<>();
SerDeInfo serdeInfo = new SerDeInfo("serde", "seriallib", new HashMap<>());
StorageDescriptor sd = new StorageDescriptor(cols, serdeLocation, "input", "output", false, 0,
serdeInfo, null, null, serdeParams);
sd.setStoredAsSubDirectories(false);
Table tbl = new Table(tblName, dbName, tblOwner, 0, 0, 0, sd, ptnCols, tblParams, null, null,
TableType.MANAGED_TABLE.toString());
tbl.setCatName(DEFAULT_CATALOG_NAME);
return tbl;
}
代码示例来源:origin: apache/hive
tbl.setCatName(defaultCat);
if (primaryKeys != null) {
primaryKeys.forEach(pk -> pk.setCatName(defaultCat));
代码示例来源:origin: apache/hive
public void createTable(Table tbl, EnvironmentContext envContext) throws AlreadyExistsException,
InvalidObjectException, MetaException, NoSuchObjectException, TException {
if (!tbl.isSetCatName()) {
tbl.setCatName(getDefaultCatalog(conf));
}
HiveMetaHook hook = getHook(tbl);
if (hook != null) {
hook.preCreateTable(tbl);
}
boolean success = false;
try {
// Subclasses can override this step (for example, for temporary tables)
create_table_with_environment_context(tbl, envContext);
if (hook != null) {
hook.commitCreateTable(tbl);
}
success = true;
}
finally {
if (!success && (hook != null)) {
try {
hook.rollbackCreateTable(tbl);
} catch (Exception e){
LOG.error("Create rollback failed with", e);
}
}
}
}
代码示例来源:origin: apache/hive
public Table build(Configuration conf) throws MetaException {
if (tableName == null) {
throw new MetaException("You must set the table name");
}
if (ownerType == null) {
ownerType = PrincipalType.USER;
}
if (owner == null) {
try {
owner = SecurityUtils.getUser();
} catch (IOException e) {
throw MetaStoreUtils.newMetaException(e);
}
}
if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf);
Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(),
partCols, tableParams, viewOriginalText, viewExpandedText, type);
if (rewriteEnabled) t.setRewriteEnabled(true);
if (temporary) t.setTemporary(temporary);
t.setCatName(catName);
if (!mvReferencedTables.isEmpty()) {
CreationMetadata cm = new CreationMetadata(catName, dbName, tableName, mvReferencedTables);
if (mvValidTxnList != null) cm.setValidTxnList(mvValidTxnList);
t.setCreationMetadata(cm);
}
return t;
}
代码示例来源:origin: apache/hive
newTable.setCatName(catName);
代码示例来源:origin: apache/hive
try {
if (!tbl.isSetCatName()) {
tbl.setCatName(getDefaultCatalog(conf));
代码示例来源:origin: apache/hive
new Table(tblName, dbName, null, 0, 0, 0, sd, partCols, new HashMap<>(),
null, null, TableType.MANAGED_TABLE.toString());
tbl.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.createTable(tbl);
代码示例来源:origin: apache/hive
new Table(tblName, dbName, null, 0, 0, 0, sd, partCols, new HashMap<>(),
null, null, TableType.MANAGED_TABLE.toString());
tbl.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.createTable(tbl);
代码示例来源:origin: apache/hive
private Table createPartitionedTable(String catName, String dbName, String tableName) throws Exception {
try {
db.dropTable(catName, dbName, tableName);
Table table = new Table();
table.setCatName(catName);
table.setDbName(dbName);
table.setTableName(tableName);
FieldSchema col1 = new FieldSchema("key", "string", "");
FieldSchema col2 = new FieldSchema("value", "int", "");
FieldSchema col3 = new FieldSchema("city", "string", "");
StorageDescriptor sd = new StorageDescriptor();
sd.setSerdeInfo(new SerDeInfo());
sd.setInputFormat(TextInputFormat.class.getCanonicalName());
sd.setOutputFormat(HiveIgnoreKeyTextOutputFormat.class.getCanonicalName());
sd.setCols(Arrays.asList(col1, col2));
table.setPartitionKeys(Arrays.asList(col3));
table.setSd(sd);
db.createTable(table);
return db.getTable(catName, dbName, tableName);
} catch (Exception exception) {
fail("Unable to drop and create table " + StatsUtils.getFullyQualifiedTableName(dbName, tableName) + " because "
+ StringUtils.stringifyException(exception));
throw exception;
}
}
代码示例来源:origin: apache/hive
private Table createPartitionedTable(String catName, String dbName, String tableName) throws Exception {
try {
db.dropTable(catName, dbName, tableName);
Table table = new Table();
table.setCatName(catName);
table.setDbName(dbName);
table.setTableName(tableName);
FieldSchema col1 = new FieldSchema("key", "string", "");
FieldSchema col2 = new FieldSchema("value", "int", "");
FieldSchema col3 = new FieldSchema("city", "string", "");
StorageDescriptor sd = new StorageDescriptor();
sd.setSerdeInfo(new SerDeInfo());
sd.setInputFormat(TextInputFormat.class.getCanonicalName());
sd.setOutputFormat(HiveIgnoreKeyTextOutputFormat.class.getCanonicalName());
sd.setCols(Arrays.asList(col1, col2));
table.setPartitionKeys(Arrays.asList(col3));
table.setSd(sd);
db.createTable(table);
return db.getTable(catName, dbName, tableName);
} catch (Exception exception) {
fail("Unable to drop and create table " + StatsUtils
.getFullyQualifiedTableName(dbName, tableName) + " because " + StringUtils
.stringifyException(exception));
throw exception;
}
}
代码示例来源:origin: apache/hive
t.setCatName(mtbl.getDatabase().getCatalogName());
t.setWriteId(mtbl.getWriteId());
return t;
代码示例来源:origin: apache/hive
new Table(tblName, dbName, null, 0, 0, 0, sd, partCols, new HashMap<>(),
null, null, TableType.MANAGED_TABLE.toString());
tbl.setCatName(DEFAULT_CATALOG_NAME);
cachedStore.createTable(tbl);
代码示例来源:origin: apache/hive
private TableWrapper createTableWrapper(String catName, String dbName, String tblName,
Table tbl) {
TableWrapper wrapper;
Table tblCopy = tbl.deepCopy();
tblCopy.setCatName(normalizeIdentifier(catName));
tblCopy.setDbName(normalizeIdentifier(dbName));
tblCopy.setTableName(normalizeIdentifier(tblName));
if (tblCopy.getPartitionKeys() != null) {
for (FieldSchema fs : tblCopy.getPartitionKeys()) {
fs.setName(normalizeIdentifier(fs.getName()));
}
}
if (tbl.getSd() != null) {
byte[] sdHash = MetaStoreServerUtils.hashStorageDescriptor(tbl.getSd(), md);
StorageDescriptor sd = tbl.getSd();
increSd(sd, sdHash);
tblCopy.setSd(null);
wrapper = new TableWrapper(tblCopy, sdHash, sd.getLocation(), sd.getParameters());
} else {
wrapper = new TableWrapper(tblCopy, null, null, null);
}
return wrapper;
}
代码示例来源:origin: apache/hive
@Test(expected = InvalidOperationException.class)
public void moveTablesBetweenCatalogsOnAlter() throws TException {
String catName = "move_table_between_catalogs_on_alter";
Catalog cat = new CatalogBuilder()
.setName(catName)
.setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName))
.build();
client.createCatalog(cat);
String dbName = "a_db";
// For this one don't specify a location to make sure it gets put in the catalog directory
Database db = new DatabaseBuilder()
.setName(dbName)
.setCatalogName(catName)
.create(client, metaStore.getConf());
String tableName = "non_movable_table";
Table before = new TableBuilder()
.inDb(db)
.setTableName(tableName)
.addCol("col1", ColumnType.STRING_TYPE_NAME)
.addCol("col2", ColumnType.INT_TYPE_NAME)
.create(client, metaStore.getConf());
Table after = before.deepCopy();
after.setCatName(DEFAULT_CATALOG_NAME);
client.alter_table(catName, dbName, tableName, after);
}
代码示例来源:origin: apache/hive
unsetCatName();
} else {
setCatName((String)value);
代码示例来源:origin: org.apache.hive/hive-standalone-metastore
public Table build(Configuration conf) throws MetaException {
if (tableName == null) {
throw new MetaException("You must set the table name");
}
if (owner == null) {
try {
owner = SecurityUtils.getUser();
} catch (IOException e) {
throw MetaStoreUtils.newMetaException(e);
}
}
if (catName == null) catName = MetaStoreUtils.getDefaultCatalog(conf);
Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(),
partCols, tableParams, viewOriginalText, viewExpandedText, type);
if (rewriteEnabled) t.setRewriteEnabled(true);
if (temporary) t.setTemporary(temporary);
t.setCatName(catName);
if (!mvReferencedTables.isEmpty()) {
CreationMetadata cm = new CreationMetadata(catName, dbName, tableName, mvReferencedTables);
if (mvValidTxnList != null) cm.setValidTxnList(mvValidTxnList);
t.setCreationMetadata(cm);
}
return t;
}
代码示例来源:origin: org.apache.hive/hive-standalone-metastore
newTable.setCatName(catName);
代码示例来源:origin: org.apache.hive/hive-standalone-metastore
try {
if (!tbl.isSetCatName()) {
tbl.setCatName(getDefaultCatalog(conf));
代码示例来源:origin: org.apache.hive/hive-standalone-metastore
t.setCatName(mtbl.getDatabase().getCatalogName());
return t;
代码示例来源:origin: org.apache.hive/hive-standalone-metastore
unsetCatName();
} else {
setCatName((String)value);
内容来源于网络,如有侵权,请联系作者删除!