本文整理了Java中org.apache.hadoop.hive.ql.metadata.Table.getDataLocation()
方法的一些代码示例,展示了Table.getDataLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getDataLocation()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Table
类名称:Table
方法名:getDataLocation
暂无
代码示例来源:origin: apache/hive
@Override
public String getLocation() {
return table.getDataLocation().toString();
}
代码示例来源:origin: apache/hive
private static Path genPartPathFromTable(Table tbl, Map<String, String> partSpec,
Path tblDataLocationPath) throws MetaException {
Path partPath = new Path(tbl.getDataLocation(), Warehouse.makePartPath(partSpec));
return new Path(tblDataLocationPath.toUri().getScheme(),
tblDataLocationPath.toUri().getAuthority(), partPath.toUri().getPath());
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public Path datasetRoot() {
return super.getTable().getDataLocation();
}
}
代码示例来源:origin: apache/incubator-gobblin
public Path getTableLocation() {
return this.hivePartition.getTable().getDataLocation();
}
代码示例来源:origin: apache/hive
/**
* Get the location of the entity.
*/
public URI getLocation() throws Exception {
if (typ == Type.DATABASE) {
String location = database.getLocationUri();
return location == null ? null : new URI(location);
}
if (typ == Type.TABLE) {
Path path = t.getDataLocation();
return path == null ? null : path.toUri();
}
if (typ == Type.PARTITION) {
Path path = p.getDataLocation();
return path == null ? null : path.toUri();
}
if (typ == Type.DFS_DIR || typ == Type.LOCAL_DIR) {
return d.toUri();
}
return null;
}
代码示例来源:origin: apache/incubator-gobblin
public ReplaceTableStageableTableMetadata(Table referenceTable) {
super(referenceTable, referenceTable.getDbName(), referenceTable.getTableName(), referenceTable.getDataLocation().toString());
}
代码示例来源:origin: apache/hive
/**
* Remove any created directories for CTEs.
*/
public void removeMaterializedCTEs() {
// clean CTE tables
for (Table materializedTable : cteTables.values()) {
Path location = materializedTable.getDataLocation();
try {
FileSystem fs = location.getFileSystem(conf);
boolean status = fs.delete(location, true);
LOG.info("Removed " + location + " for materialized "
+ materializedTable.getTableName() + ", status=" + status);
} catch (IOException e) {
// ignore
LOG.warn("Error removing " + location + " for materialized " + materializedTable.getTableName() +
": " + StringUtils.stringifyException(e));
}
}
cteTables.clear();
}
代码示例来源:origin: apache/incubator-gobblin
/**
* Get the update time of a {@link Table}
* @return the update time if available, 0 otherwise
*
* {@inheritDoc}
* @see HiveUnitUpdateProvider#getUpdateTime(org.apache.hadoop.hive.ql.metadata.Table)
*/
@Override
public long getUpdateTime(Table table) throws UpdateNotFoundException {
try {
return getUpdateTime(table.getDataLocation());
} catch (IOException e) {
throw new UpdateNotFoundException(String.format("Failed to get update time for %s.", table.getCompleteName()), e);
}
}
代码示例来源:origin: apache/hive
/**
* Creates path where partitions matching prefix should lie in filesystem
* @param tbl table in which partition is
* @return expected location of partitions matching prefix in filesystem
*/
public Path createPath(Table tbl) throws HiveException {
String prefixSubdir;
try {
prefixSubdir = Warehouse.makePartName(fields, values);
} catch (MetaException e) {
throw new HiveException("Unable to get partitions directories prefix", e);
}
Path tableDir = tbl.getDataLocation();
if (tableDir == null) {
throw new HiveException("Table has no location set");
}
return new Path(tableDir, prefixSubdir);
}
/**
代码示例来源:origin: apache/drill
/**
* Creates path where partitions matching prefix should lie in filesystem
* @param tbl table in which partition is
* @return expected location of partitions matching prefix in filesystem
*/
public Path createPath(Table tbl) throws HiveException {
String prefixSubdir;
try {
prefixSubdir = Warehouse.makePartName(fields, values);
} catch (MetaException e) {
throw new HiveException("Unable to get partitions directories prefix", e);
}
Path tableDir = tbl.getDataLocation();
if(tableDir == null) {
throw new HiveException("Table has no location set");
}
return new Path(tableDir, prefixSubdir);
}
/**
代码示例来源:origin: apache/incubator-gobblin
private DatasetDescriptor createSourceDataset() {
try {
String sourceTable = getTable().getDbName() + "." + getTable().getTableName();
DatasetDescriptor source = new DatasetDescriptor(DatasetConstants.PLATFORM_HIVE, sourceTable);
Path sourcePath = getTable().getDataLocation();
log.info(String.format("[%s]Source path %s being used in conversion", this.getClass().getName(), sourcePath));
String sourceLocation = Path.getPathWithoutSchemeAndAuthority(sourcePath).toString();
FileSystem sourceFs = sourcePath.getFileSystem(new Configuration());
source.addMetadata(DatasetConstants.FS_SCHEME, sourceFs.getScheme());
source.addMetadata(DatasetConstants.FS_LOCATION, sourceLocation);
return source;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/incubator-gobblin
public static HiveLocationDescriptor forTable(Table table, FileSystem fs, Properties properties) throws IOException {
return new HiveLocationDescriptor(table.getDataLocation(), HiveUtils.getInputFormat(table.getTTable().getSd()), fs, properties);
}
代码示例来源:origin: apache/hive
private void writeData(PartitionIterable partitions) throws SemanticException {
try {
if (tableSpec.tableHandle.isPartitioned()) {
if (partitions == null) {
throw new IllegalStateException("partitions cannot be null for partitionTable :"
+ tableSpec.tableName);
}
new PartitionExport(paths, partitions, distCpDoAsUser, conf, mmCtx).write(replicationSpec);
} else {
List<Path> dataPathList = Utils.getDataPathList(tableSpec.tableHandle.getDataLocation(),
replicationSpec, conf);
// this is the data copy
new FileOperations(dataPathList, paths.dataExportDir(), distCpDoAsUser, conf, mmCtx)
.export(replicationSpec);
}
} catch (Exception e) {
throw new SemanticException(e.getMessage(), e);
}
}
代码示例来源:origin: apache/incubator-gobblin
public HiveDataset(FileSystem fs, HiveMetastoreClientPool clientPool, Table table, Properties properties, Config datasetConfig) {
this.fs = fs;
this.clientPool = clientPool;
this.table = table;
this.properties = properties;
this.tableRootPath = PathUtils.isGlob(this.table.getDataLocation()) ? Optional.<Path> absent() :
Optional.fromNullable(this.table.getDataLocation());
this.tableIdentifier = this.table.getDbName() + "." + this.table.getTableName();
this.datasetNamePattern = Optional.fromNullable(ConfigUtils.getString(datasetConfig, DATASET_NAME_PATTERN_KEY, null));
this.dbAndTable = new DbAndTable(table.getDbName(), table.getTableName());
if (this.datasetNamePattern.isPresent()) {
this.logicalDbAndTable = parseLogicalDbAndTable(this.datasetNamePattern.get(), this.dbAndTable, LOGICAL_DB_TOKEN, LOGICAL_TABLE_TOKEN);
} else {
this.logicalDbAndTable = this.dbAndTable;
}
this.datasetConfig = resolveConfig(datasetConfig, dbAndTable, logicalDbAndTable);
this.metricContext = Instrumented.getMetricContext(new State(properties), HiveDataset.class,
Lists.<Tag<?>> newArrayList(new Tag<>(DATABASE, table.getDbName()), new Tag<>(TABLE, table.getTableName())));
}
代码示例来源:origin: apache/hive
@Test(expected = MetastoreException.class)
public void testInvalidPartitionKeyName()
throws HiveException, AlreadyExistsException, IOException, MetastoreException {
Table table = createTestTable();
List<Partition> partitions = hive.getPartitions(table);
assertEquals(2, partitions.size());
// add a fake partition dir on fs
fs = partitions.get(0).getDataLocation().getFileSystem(hive.getConf());
Path fakePart = new Path(table.getDataLocation().toString(),
"fakedate=2009-01-01/fakecity=sanjose");
fs.mkdirs(fakePart);
fs.deleteOnExit(fakePart);
checker.checkMetastore(catName, dbName, tableName, null, new CheckResult());
}
代码示例来源:origin: apache/drill
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl,
boolean isOutputPadded) {
formatOutput("Database:", tbl.getDbName(), tableInfo);
formatOutput("Owner:", tbl.getOwner(), tableInfo);
formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo);
formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo);
formatOutput("Retention:", Integer.toString(tbl.getRetention()), tableInfo);
if (!tbl.isView()) {
formatOutput("Location:", tbl.getDataLocation().toString(), tableInfo);
}
formatOutput("Table Type:", tbl.getTableType().name(), tableInfo);
if (tbl.getParameters().size() > 0) {
tableInfo.append("Table Parameters:").append(LINE_DELIM);
displayAllParameters(tbl.getParameters(), tableInfo, false, isOutputPadded);
}
}
代码示例来源:origin: apache/hive
public static void addMapWork(MapredWork mr, Table tbl, String alias, Operator<?> work) {
mr.getMapWork().addMapWork(tbl.getDataLocation(), alias, work, new PartitionDesc(
Utilities.getTableDesc(tbl), null));
}
代码示例来源:origin: apache/hive
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl,
boolean isOutputPadded) {
formatOutput("Database:", tbl.getDbName(), tableInfo);
formatOutput("OwnerType:", (tbl.getOwnerType() != null) ? tbl.getOwnerType().name() : "null", tableInfo);
formatOutput("Owner:", tbl.getOwner(), tableInfo);
formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo);
formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo);
formatOutput("Retention:", Integer.toString(tbl.getRetention()), tableInfo);
if (!tbl.isView()) {
formatOutput("Location:", tbl.getDataLocation().toString(), tableInfo);
}
formatOutput("Table Type:", tbl.getTableType().name(), tableInfo);
if (tbl.getParameters().size() > 0) {
tableInfo.append("Table Parameters:").append(LINE_DELIM);
displayAllParameters(tbl.getParameters(), tableInfo, false, isOutputPadded);
}
}
代码示例来源:origin: apache/hive
@Test
public void testAdditionalPartitionDirs()
throws HiveException, AlreadyExistsException, IOException, MetastoreException {
Table table = createTestTable();
List<Partition> partitions = hive.getPartitions(table);
assertEquals(2, partitions.size());
// add a fake partition dir on fs
fs = partitions.get(0).getDataLocation().getFileSystem(hive.getConf());
Path fakePart = new Path(table.getDataLocation().toString(),
partDateName + "=2017-01-01/" + partCityName + "=paloalto/fakePartCol=fakepartValue");
fs.mkdirs(fakePart);
fs.deleteOnExit(fakePart);
CheckResult result = new CheckResult();
checker.checkMetastore(catName, dbName, tableName, null, result);
assertEquals(Collections.<String> emptySet(), result.getTablesNotInMs());
assertEquals(Collections.<String> emptySet(), result.getTablesNotOnFs());
assertEquals(Collections.<CheckResult.PartitionResult> emptySet(), result.getPartitionsNotOnFs());
//fakePart path partition is added since the defined partition keys are valid
assertEquals(1, result.getPartitionsNotInMs().size());
}
代码示例来源:origin: apache/hive
@Test
public void testSkipInvalidPartitionKeyName()
throws HiveException, AlreadyExistsException, IOException, MetastoreException {
hive.getConf().set(HiveConf.ConfVars.HIVE_MSCK_PATH_VALIDATION.varname, "skip");
checker = new HiveMetaStoreChecker(msc, hive.getConf());
Table table = createTestTable();
List<Partition> partitions = hive.getPartitions(table);
assertEquals(2, partitions.size());
// add a fake partition dir on fs
fs = partitions.get(0).getDataLocation().getFileSystem(hive.getConf());
Path fakePart =
new Path(table.getDataLocation().toString(), "fakedate=2009-01-01/fakecity=sanjose");
fs.mkdirs(fakePart);
fs.deleteOnExit(fakePart);
createPartitionsDirectoriesOnFS(table, 2);
CheckResult result = new CheckResult();
checker.checkMetastore(catName, dbName, tableName, null, result);
assertEquals(Collections.<String> emptySet(), result.getTablesNotInMs());
assertEquals(Collections.<String> emptySet(), result.getTablesNotOnFs());
assertEquals(Collections.<CheckResult.PartitionResult> emptySet(), result.getPartitionsNotOnFs());
// only 2 valid partitions should be added
assertEquals(2, result.getPartitionsNotInMs().size());
}
内容来源于网络,如有侵权,请联系作者删除!