Search in sources :

Example 6 with Table

use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.

the class TableDaoImpl method getBySourceDatabaseTableName.

@Override
public Table getBySourceDatabaseTableName(final String sourceName, final String databaseName, final String tableName) {
    Table result = null;
    final List<Table> tables = getBySourceDatabaseTableNames(sourceName, databaseName, Lists.newArrayList(tableName));
    if (!tables.isEmpty()) {
        result = tables.get(0);
    }
    return result;
}
Also used : Table(com.netflix.metacat.connector.s3.model.Table)

Example 7 with Table

use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.

the class S3ConnectorPartitionService method update.

@Override
public void update(@Nonnull final ConnectorContext context, @Nonnull final PartitionInfo partitionInfo) {
    final QualifiedName name = partitionInfo.getName();
    log.debug("Start: Update partition {}", name);
    final QualifiedName tableName = QualifiedName.ofTable(catalogName, name.getDatabaseName(), name.getTableName());
    // Table
    final Table table = getTable(tableName);
    final List<Partition> partitions = partitionDao.getPartitions(table.getId(), Lists.newArrayList(name.getPartitionName()), null, null, null, null);
    if (partitions.isEmpty()) {
        throw new PartitionNotFoundException(tableName, name.getPartitionName());
    }
    partitionDao.save(infoConverter.fromPartitionInfo(partitionInfo));
    log.debug("End: Update partition {}", name);
}
Also used : Partition(com.netflix.metacat.connector.s3.model.Partition) FilterPartition(com.netflix.metacat.common.server.partition.util.FilterPartition) PartitionNotFoundException(com.netflix.metacat.common.server.connectors.exception.PartitionNotFoundException) Table(com.netflix.metacat.connector.s3.model.Table) QualifiedName(com.netflix.metacat.common.QualifiedName)

Example 8 with Table

use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.

the class S3ConnectorPartitionService method exists.

@Override
public boolean exists(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name) {
    boolean result = false;
    final Table table = tableDao.getBySourceDatabaseTableName(catalogName, name.getDatabaseName(), name.getTableName());
    if (table != null) {
        result = !partitionDao.getPartitions(table.getId(), Lists.newArrayList(name.getPartitionName()), null, null, null, null).isEmpty();
    }
    return result;
}
Also used : Table(com.netflix.metacat.connector.s3.model.Table)

Example 9 with Table

use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.

the class S3ConnectorTableService method rename.

@Override
public void rename(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName oldName, @Nonnull final QualifiedName newName) {
    log.debug("Start: Rename table {} with {}", oldName, newName);
    final Table oldTable = tableDao.getBySourceDatabaseTableName(catalogName, oldName.getDatabaseName(), oldName.getTableName());
    if (oldTable == null) {
        throw new TableNotFoundException(oldName);
    }
    final Table newTable = tableDao.getBySourceDatabaseTableName(catalogName, newName.getDatabaseName(), newName.getTableName());
    if (newTable == null) {
        oldTable.setName(newName.getTableName());
        tableDao.save(oldTable);
    } else {
        throw new TableAlreadyExistsException(newName);
    }
    log.debug("End: Rename table {} with {}", oldName, newName);
}
Also used : TableNotFoundException(com.netflix.metacat.common.server.connectors.exception.TableNotFoundException) TableAlreadyExistsException(com.netflix.metacat.common.server.connectors.exception.TableAlreadyExistsException) Table(com.netflix.metacat.connector.s3.model.Table)

Example 10 with Table

use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.

the class S3ConnectorTableService method get.

@Override
public TableInfo get(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name) {
    final Table table = tableDao.getBySourceDatabaseTableName(catalogName, name.getDatabaseName(), name.getTableName());
    if (table == null) {
        throw new TableNotFoundException(name);
    }
    log.debug("Get table {}", name);
    return infoConverter.toTableInfo(name, table);
}
Also used : TableNotFoundException(com.netflix.metacat.common.server.connectors.exception.TableNotFoundException) Table(com.netflix.metacat.connector.s3.model.Table)

Aggregations

Table (com.netflix.metacat.connector.s3.model.Table)13 QualifiedName (com.netflix.metacat.common.QualifiedName)7 Location (com.netflix.metacat.connector.s3.model.Location)7 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)6 Partition (com.netflix.metacat.connector.s3.model.Partition)6 FieldInfo (com.netflix.metacat.common.server.connectors.model.FieldInfo)5 PartitionInfo (com.netflix.metacat.common.server.connectors.model.PartitionInfo)5 FilterPartition (com.netflix.metacat.common.server.partition.util.FilterPartition)5 PartitionNotFoundException (com.netflix.metacat.common.server.connectors.exception.PartitionNotFoundException)4 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)4 Field (com.netflix.metacat.connector.s3.model.Field)4 Info (com.netflix.metacat.connector.s3.model.Info)4 Schema (com.netflix.metacat.connector.s3.model.Schema)4 PartitionAlreadyExistsException (com.netflix.metacat.common.server.connectors.exception.PartitionAlreadyExistsException)3 AuditInfo (com.netflix.metacat.common.server.connectors.model.AuditInfo)3 DatabaseInfo (com.netflix.metacat.common.server.connectors.model.DatabaseInfo)3 StorageInfo (com.netflix.metacat.common.server.connectors.model.StorageInfo)3 Strings (com.google.common.base.Strings)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2