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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations