public static Path getTableDefaultLocation(HdfsContext context, SemiTransactionalHiveMetastore metastore, HdfsEnvironment hdfsEnvironment, String schemaName, String tableName)
{
Optional<String> location = getDatabase(metastore, schemaName).getLocation();
if (!location.isPresent() || location.get().isEmpty()) {
throw new PrestoException(HIVE_DATABASE_LOCATION_ERROR, format("Database '%s' location is not set", schemaName));
}
Path databasePath = new Path(location.get());
if (!isS3FileSystem(context, hdfsEnvironment, databasePath)) {
if (!pathExists(context, hdfsEnvironment, databasePath)) {
throw new PrestoException(HIVE_DATABASE_LOCATION_ERROR, format("Database '%s' location does not exist: %s", schemaName, databasePath));
}
if (!isDirectory(context, hdfsEnvironment, databasePath)) {
throw new PrestoException(HIVE_DATABASE_LOCATION_ERROR, format("Database '%s' location is not a directory: %s", schemaName, databasePath));
}
}
return new Path(databasePath, tableName);
}