本文整理汇总了Java中org.apache.hadoop.hive.metastore.api.Table.getDbName方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getDbName方法的具体用法?Java Table.getDbName怎么用?Java Table.getDbName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.metastore.api.Table
的用法示例。
在下文中一共展示了Table.getDbName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HiveTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
public HiveTable(Table table) {
if (table == null) {
return;
}
this.table = table;
this.tableName = table.getTableName();
this.dbName = table.getDbName();
this.owner = table.getOwner();
this.createTime = table.getCreateTime();
this.lastAccessTime = table.getLastAccessTime();
this.retention = table.getRetention();
this.sd = new StorageDescriptorWrapper(table.getSd());
this.partitionKeys = Lists.newArrayList();
for (FieldSchema f : table.getPartitionKeys()) {
this.partitionKeys.add(new FieldSchemaWrapper(f));
partitionNameTypeMap.put(f.getName(), f.getType());
}
this.parameters = table.getParameters();
this.viewOriginalText = table.getViewOriginalText();
this.viewExpandedText = table.getViewExpandedText();
this.tableType = table.getTableType();
}
示例2: getDatasetBuilder
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
/**
* @return null if datasetPath is not canonical and couldn't find a corresponding table in the source
*/
static DatasetBuilder getDatasetBuilder(
HiveClient client,
String user,
NamespaceKey datasetPath,
boolean isCanonicalDatasetPath,
boolean ignoreAuthzErrors,
HiveConf hiveConf,
DatasetConfig oldConfig) throws TException {
final List<String> noSourceSchemaPath =
datasetPath.getPathComponents().subList(1, datasetPath.getPathComponents().size());
// extract database and table names from dataset path
final String dbName;
final String tableName;
switch (noSourceSchemaPath.size()) {
case 1:
dbName = "default";
tableName = noSourceSchemaPath.get(0);
break;
case 2:
dbName = noSourceSchemaPath.get(0);
tableName = noSourceSchemaPath.get(1);
break;
default:
//invalid.
return null;
}
// if the dataset path is not canonized we need to get it from the source
final Table table;
final String canonicalTableName;
final String canonicalDbName;
if (isCanonicalDatasetPath) {
canonicalDbName = dbName;
canonicalTableName = tableName;
table = null;
} else {
// passed datasetPath is not canonical, we need to get it from the source
table = client.getTable(dbName, tableName, ignoreAuthzErrors);
if(table == null){
return null;
}
canonicalTableName = table.getTableName();
canonicalDbName = table.getDbName();
}
final List<String> canonicalDatasetPath = Lists.newArrayList(datasetPath.getRoot(), canonicalDbName, canonicalTableName);
return new DatasetBuilder(client, user, new NamespaceKey(canonicalDatasetPath), ignoreAuthzErrors, hiveConf, canonicalDbName, canonicalTableName, table, oldConfig);
}
示例3: getMonarchTableName
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
/**
* Get the Monarch TableName.
*
* @param tbl the hive Table containing Monarch tableName.
* @return the String Monarch TableName
*/
protected String getMonarchTableName(Table tbl) {
// 1. If region name property is not provided use hive's table name.
// 2. Use '_'(underscore) instead of '.'(dot) since gemfire
// does not allow querying when region name contain dot.
String tableName = tbl.getParameters().get(MonarchUtils.REGION);
if (tableName == null) {
tableName = tbl.getDbName() + "_" + tbl.getTableName();
}
return tableName;
}
示例4: get_table_req
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
@Test
public void get_table_req() throws MetaException, NoSuchObjectException, TException {
Table table = new Table();
table.setDbName(DB_P);
table.setTableName("table");
GetTableRequest request = new GetTableRequest(table.getDbName(), table.getTableName());
GetTableResult response = new GetTableResult(table);
when(primaryClient.get_table_req(request)).thenReturn(response);
when(primaryMapping.transformInboundGetTableRequest(request)).thenReturn(request);
when(primaryMapping.transformOutboundGetTableResult(response)).thenReturn(response);
GetTableResult result = handler.get_table_req(request);
assertThat(result.getTable().getDbName(), is(DB_P));
assertThat(result.getTable().getTableName(), is("table"));
}
示例5: preCreateTable
import org.apache.hadoop.hive.metastore.api.Table; //导入方法依赖的package包/类
public void preCreateTable(Table table) throws MetaException {
// We want data to be stored in monarch, nowwhere else.
if (table.getSd().getLocation() != null) {
throw new MetaException("Location can't be specified for Monarch");
}
boolean isExternal = isExternalTable(table);
String tableName = getMonarchTableName(table);
String hiveTableName = table.getDbName() + "_" + table.getTableName();
Map<String, String> columnInfo = new LinkedHashMap<>();
Iterator<FieldSchema> columnIterator = table.getSd().getColsIterator();
if (columnIterator != null) {
while (columnIterator.hasNext()) {
FieldSchema e = columnIterator.next();
columnInfo.put(e.getName(), e.getType());
}
}
try {
Map<String, String> parameters = table.getParameters();
String tableType = parameters.getOrDefault(MonarchUtils.MONARCH_TABLE_TYPE, MonarchUtils.DEFAULT_TABLE_TYPE);
if (tableType.equalsIgnoreCase(MonarchUtils.DEFAULT_TABLE_TYPE)) {
MonarchUtils.createConnectionAndFTable(tableName, parameters, isExternal, hiveTableName, columnInfo);
} else {
MonarchUtils.createConnectionAndTable(tableName, parameters, isExternal, hiveTableName, columnInfo);
}
} catch (Exception se) {
LOG.error("Failed to create table: {}", tableName, se);
throw new MetaException(se.getMessage());
}
}