use of io.prestosql.plugin.hive.LocationHandle in project hetu-core by openlookeng.
the class CarbondataLocationService method forNewTable.
@Override
public LocationHandle forNewTable(SemiTransactionalHiveMetastore metastore, ConnectorSession session, String schemaName, String tableName, Optional<WriteIdInfo> writeIdInfo, Optional<Path> tablePath, HiveWriteUtils.OpertionType opertionType) {
// TODO: check and make it compatible for cloud scenario
super.forNewTable(metastore, session, schemaName, tableName, writeIdInfo, tablePath, opertionType);
Path targetPath;
HdfsEnvironment.HdfsContext context = new HdfsEnvironment.HdfsContext(session, schemaName, tableName);
if (tablePath.isPresent()) {
targetPath = tablePath.get();
} else {
targetPath = getTableDefaultLocation(context, metastore, hdfsEnvironment, schemaName, tableName);
}
if (pathExists(context, hdfsEnvironment, targetPath)) {
throw new PrestoException(HIVE_PATH_ALREADY_EXISTS, format("Target directory for table '%s.%s' already exists: %s", schemaName, tableName, targetPath));
}
return new LocationHandle(targetPath, targetPath, false, LocationHandle.WriteMode.DIRECT_TO_TARGET_NEW_DIRECTORY, writeIdInfo);
}
Aggregations