Search in sources :

Example 6 with LocationHandle

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);
}
Also used : Path(org.apache.hadoop.fs.Path) PrestoException(io.prestosql.spi.PrestoException) HdfsEnvironment(io.prestosql.plugin.hive.HdfsEnvironment) LocationHandle(io.prestosql.plugin.hive.LocationHandle)

Aggregations

LocationHandle (io.prestosql.plugin.hive.LocationHandle)6 Path (org.apache.hadoop.fs.Path)6 HdfsEnvironment (io.prestosql.plugin.hive.HdfsEnvironment)4 PrestoException (io.prestosql.spi.PrestoException)4 BaseStorageFormat (io.prestosql.plugin.hive.BaseStorageFormat)2 HiveBasicStatistics (io.prestosql.plugin.hive.HiveBasicStatistics)2 HiveColumnHandle (io.prestosql.plugin.hive.HiveColumnHandle)2 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)2 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 Gson (com.google.gson.Gson)1 JsonCodec (io.airlift.json.JsonCodec)1 Slice (io.airlift.slice.Slice)1 Duration (io.airlift.units.Duration)1 EncodedLoadModel (io.hetu.core.plugin.carbondata.CarbondataConstants.EncodedLoadModel)1 CarbondataTableProperties.getCarbondataLocation (io.hetu.core.plugin.carbondata.CarbondataTableProperties.getCarbondataLocation)1