Search in sources :

Example 1 with Info

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

the class S3ConnectorInfoConverter method toFields.

/**
     * Creates list of fields from table info.
     * @param tableInfo table info
     * @param schema schema
     * @return list of fields
     */
public List<Field> toFields(final TableInfo tableInfo, final Schema schema) {
    final ImmutableList.Builder<Field> columns = ImmutableList.builder();
    int index = 0;
    for (FieldInfo fieldInfo : tableInfo.getFields()) {
        final Field field = toField(fieldInfo);
        field.setPos(index++);
        field.setSchema(schema);
        columns.add(field);
    }
    return columns.build();
}
Also used : Field(com.netflix.metacat.connector.s3.model.Field) ImmutableList(com.google.common.collect.ImmutableList) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo)

Example 2 with Info

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

the class S3ConnectorInfoConverter method toAuditInfo.

/**
     * Creates audit info from s3 table info.
     * @param table table info
     * @return audit info
     */
public AuditInfo toAuditInfo(final Table table) {
    final AuditInfo result = AuditInfo.builder().createdDate(table.getCreatedDate()).lastModifiedDate(table.getLastUpdatedDate()).build();
    final Location location = table.getLocation();
    if (location != null) {
        final Info info = location.getInfo();
        if (info != null) {
            result.setCreatedBy(info.getOwner());
            result.setLastModifiedBy(info.getOwner());
        }
    }
    return result;
}
Also used : AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo) AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo) DatabaseInfo(com.netflix.metacat.common.server.connectors.model.DatabaseInfo) FieldInfo(com.netflix.metacat.common.server.connectors.model.FieldInfo) PartitionInfo(com.netflix.metacat.common.server.connectors.model.PartitionInfo) StorageInfo(com.netflix.metacat.common.server.connectors.model.StorageInfo) Info(com.netflix.metacat.connector.s3.model.Info) TableInfo(com.netflix.metacat.common.server.connectors.model.TableInfo) Location(com.netflix.metacat.connector.s3.model.Location)

Example 3 with Info

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

the class S3ConnectorInfoConverter method partitionKeys.

/**
     * Gets the partition keys for the given table.
     * @param table table info
     * @return list of keys
     */
public List<String> partitionKeys(final Table table) {
    List<String> result = Lists.newArrayList();
    if (table.getLocation() != null) {
        final Schema schema = table.getLocation().getSchema();
        if (schema != null) {
            final List<Field> fields = schema.getFields();
            result = fields.stream().filter(Field::isPartitionKey).map(Field::getName).collect(Collectors.toList());
        }
    }
    return result;
}
Also used : Field(com.netflix.metacat.connector.s3.model.Field) Schema(com.netflix.metacat.connector.s3.model.Schema)

Example 4 with Info

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

the class S3ConnectorInfoConverter method fromPartitionInfo.

/**
     * Converts from partition info to s3 partition object.
     * @param partitionInfo partition info
     * @return s3 partition
     */
Partition fromPartitionInfo(final PartitionInfo partitionInfo) {
    final Partition result = new Partition();
    result.setName(partitionInfo.getName().getPartitionName());
    result.setUri(partitionInfo.getSerde().getUri());
    final AuditInfo auditInfo = partitionInfo.getAudit();
    if (auditInfo != null) {
        result.setCreatedDate(auditInfo.getCreatedDate());
        result.setLastUpdatedDate(auditInfo.getLastModifiedDate());
    }
    return result;
}
Also used : Partition(com.netflix.metacat.connector.s3.model.Partition) AuditInfo(com.netflix.metacat.common.server.connectors.model.AuditInfo)

Example 5 with Info

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

the class S3ConnectorInfoConverter method toLocation.

/**
     * Creates location.
     * @param tableInfo table info
     * @return location
     */
public Location toLocation(final TableInfo tableInfo) {
    final Location location = fromStorageInfo(tableInfo.getSerde());
    final Schema schema = new Schema();
    schema.setLocation(location);
    schema.setFields(toFields(tableInfo, schema));
    location.setSchema(schema);
    return location;
}
Also used : Schema(com.netflix.metacat.connector.s3.model.Schema) Location(com.netflix.metacat.connector.s3.model.Location)

Aggregations

Location (com.netflix.metacat.connector.s3.model.Location)6 AuditInfo (com.netflix.metacat.common.server.connectors.model.AuditInfo)5 FieldInfo (com.netflix.metacat.common.server.connectors.model.FieldInfo)5 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)5 Info (com.netflix.metacat.connector.s3.model.Info)5 DatabaseInfo (com.netflix.metacat.common.server.connectors.model.DatabaseInfo)4 PartitionInfo (com.netflix.metacat.common.server.connectors.model.PartitionInfo)4 StorageInfo (com.netflix.metacat.common.server.connectors.model.StorageInfo)4 Field (com.netflix.metacat.connector.s3.model.Field)3 Schema (com.netflix.metacat.connector.s3.model.Schema)3 Partition (com.netflix.metacat.connector.s3.model.Partition)2 Table (com.netflix.metacat.connector.s3.model.Table)2 ImmutableList (com.google.common.collect.ImmutableList)1 QualifiedName (com.netflix.metacat.common.QualifiedName)1 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)1