private static Schema assignFreshIds(Schema schema) { AtomicInteger lastColumnId = new AtomicInteger(0); return TypeUtil.assignFreshIds(schema, lastColumnId::incrementAndGet); } }
private static Schema assignFreshIds(Schema schema) { AtomicInteger lastColumnId = new AtomicInteger(0); return TypeUtil.assignFreshIds(schema, lastColumnId::incrementAndGet); } }
public TableMetadata buildReplacement(Schema schema, PartitionSpec partitionSpec, Map<String, String> properties) { AtomicInteger lastColumnId = new AtomicInteger(0); Schema freshSchema = TypeUtil.assignFreshIds(schema, lastColumnId::incrementAndGet);
public static TableMetadata newTableMetadata(TableOperations ops, Schema schema, PartitionSpec spec, String location, Map<String, String> properties) { // reassign all column ids to ensure consistency AtomicInteger lastColumnId = new AtomicInteger(0); Schema freshSchema = TypeUtil.assignFreshIds(schema, lastColumnId::incrementAndGet); // rebuild the partition spec using the new column ids PartitionSpec.Builder specBuilder = PartitionSpec.builderFor(freshSchema) .withSpecId(INITIAL_SPEC_ID); for (PartitionField field : spec.fields()) { // look up the name of the source field in the old schema to get the new schema's id String sourceName = schema.findColumnName(field.sourceId()); specBuilder.add( freshSchema.findField(sourceName).fieldId(), field.name(), field.transform().toString()); } PartitionSpec freshSpec = specBuilder.build(); return new TableMetadata(ops, null, location, System.currentTimeMillis(), lastColumnId.get(), freshSchema, INITIAL_SPEC_ID, ImmutableList.of(freshSpec), ImmutableMap.copyOf(properties), -1, ImmutableList.of(), ImmutableList.of()); }
TypeUtil.assignFreshIds(type, this::assignNewColumnId)));