You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/10/26 23:20:23 UTC
[GitHub] [iceberg] jackye1995 commented on a change in pull request #3352: AWS: Add column parameters for Glue catalog table schema
jackye1995 commented on a change in pull request #3352:
URL: https://github.com/apache/iceberg/pull/3352#discussion_r736991437
##########
File path: aws/src/main/java/org/apache/iceberg/aws/glue/IcebergToGlueConverter.java
##########
@@ -231,4 +226,63 @@ private static String toTypeString(Type type) {
return type.typeId().name().toLowerCase(Locale.ENGLISH);
}
}
+
+ private static List<Column> toColumns(TableMetadata metadata) {
+ List<Column> columns = new ArrayList<>();
+ Set<NestedField> rootColumnSet = new HashSet<>();
+ // Add schema-column fields
+ for (NestedField field : metadata.schema().columns()) {
+ rootColumnSet.add(field);
+ columns.add(Column.builder()
+ .name(field.name())
+ .type(toTypeString(field.type()))
+ .comment(field.doc())
+ .parameters(convertToParameters("schema-column", field))
+ .build());
+ }
+ // Add schema-subfield
+ for (NestedField field : TypeUtil.indexById(metadata.schema().asStruct()).values()) {
+ if (!rootColumnSet.contains(field)) {
+ columns.add(Column.builder()
+ .name(field.name())
+ .type(toTypeString(field.type()))
+ .comment(field.doc())
+ .parameters(convertToParameters("schema-subfield", field))
+ .build());
+ }
+ }
+ // Add partition-field
+ for (PartitionField partitionField : metadata.spec().fields()) {
+ Type type = partitionField.transform()
+ .getResultType(metadata.schema().findField(partitionField.sourceId()).type());
+ columns.add(Column.builder()
+ .name(partitionField.name())
+ .type(toTypeString(type))
+ .parameters(convertToParameters(type, partitionField))
+ .build());
+ }
+ return columns;
+ }
+
+ private static Map<String, String> convertToParameters(String fieldUsage, NestedField nestedField) {
+ Map<String, String> columnParameters = new HashMap<>();
+ columnParameters.put("iceberg.field.usage", fieldUsage);
Review comment:
nit: move these constants as static variables
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org