public List toColumns()

in xtable-aws/src/main/java/org/apache/xtable/glue/GlueSchemaExtractor.java [74:104]


  public List<Column> toColumns(
      String tableFormat, InternalSchema tableSchema, Table existingTable) {
    List<Column> columns = Lists.newArrayList();
    Set<String> addedNames = Sets.newHashSet();
    for (InternalField field : tableSchema.getFields()) {
      if (!addedNames.contains(field.getName())) {
        columns.add(toColumn(field, tableFormat));
        addedNames.add(field.getName());
      }
    }

    // if there are columns in existing glueTable that are not part of tableSchema,
    // include them by setting "field.current" property to false
    List<Column> existingColumns =
        existingTable != null && existingTable.storageDescriptor() != null
            ? existingTable.storageDescriptor().columns()
            : Collections.emptyList();
    for (Column column : existingColumns) {
      if (!addedNames.contains(column.name())) {
        Map<String, String> columnParams = new HashMap<>();
        if (column.hasParameters()) {
          columnParams.putAll(column.parameters());
        }
        columnParams.put(getColumnProperty(tableFormat, FIELD_CURRENT), "false");
        column = column.toBuilder().parameters(columnParams).build();
        columns.add(column);
        addedNames.add(column.name());
      }
    }
    return columns;
  }