@Test public void testAddFields() { Schema expected = new Schema( required(1, "id", Types.IntegerType.get()), optional(2, "data", Types.StringType.get()), optional(3, "preferences", Types.StructType.of( required(8, "feature1", Types.BooleanType.get()), optional(9, "feature2", Types.BooleanType.get()) ), "struct of named boolean options"), required(4, "locations", Types.MapType.ofRequired(10, 11, Types.StructType.of( required(20, "address", Types.StringType.get()), required(21, "city", Types.StringType.get()), required(22, "state", Types.StringType.get()), required(23, "zip", Types.IntegerType.get()) ), Types.StructType.of( required(12, "lat", Types.FloatType.get()), required(13, "long", Types.FloatType.get()), optional(25, "alt", Types.FloatType.get()) )), "map of address to coordinate"), optional(5, "points", Types.ListType.ofOptional(14, Types.StructType.of( required(15, "x", Types.LongType.get()), required(16, "y", Types.LongType.get()), optional(26, "z", Types.LongType.get()), optional(27, "t.t", Types.LongType.get()) )), "2-D cartesian points"), required(6, "doubles", Types.ListType.ofRequired(17, Types.DoubleType.get() )), optional(7, "properties", Types.MapType.ofOptional(18, 19, Types.StringType.get(), Types.StringType.get() ), "string map of properties"), optional(24, "toplevel", Types.DecimalType.of(9, 2)) ); Schema added = new SchemaUpdate(SCHEMA, SCHEMA_LAST_COLUMN_ID) .addColumn("toplevel", Types.DecimalType.of(9, 2)) .addColumn("locations", "alt", Types.FloatType.get()) .addColumn("points", "z", Types.LongType.get()) .addColumn("points", "t.t", Types.LongType.get()) .apply(); Assert.assertEquals("Should match with added fields", expected.asStruct(), added.asStruct()); }
private static List<Types.NestedField> addFields(List<Types.NestedField> fields, Collection<Types.NestedField> adds) { List<Types.NestedField> newFields = Lists.newArrayList(fields); newFields.addAll(adds); return newFields; }
SchemaUpdate implements UpdateSchema { private static List<Types.NestedField> addFields(List<Types.NestedField> fields, Collection<Types.NestedField> adds) { List<Types.NestedField> newFields = Lists.newArrayList(fields); newFields.addAll(adds); return newFields; } }
SchemaUpdate implements UpdateSchema { private static List<Types.NestedField> addFields(List<Types.NestedField> fields, Collection<Types.NestedField> adds) { List<Types.NestedField> newFields = Lists.newArrayList(fields); newFields.addAll(adds); return newFields; } SchemaUpdate(TableOperations ops);   SchemaUpdate(Schema schema, int lastColumnId); }
SchemaUpdate implements UpdateSchema { private static List<Types.NestedField> addFields(List<Types.NestedField> fields, Collection<Types.NestedField> adds) { List<Types.NestedField> newFields = Lists.newArrayList(fields); newFields.addAll(adds); return newFields; } SchemaUpdate(TableOperations ops);   SchemaUpdate(Schema schema, int lastColumnId); @Override SchemaUpdate allowIncompatibleChanges(); @Override UpdateSchema addColumn(String name, Type type, String doc); @Override UpdateSchema addColumn(String parent, String name, Type type, String doc); @Override UpdateSchema addRequiredColumn(String name, Type type, String doc); @Override UpdateSchema addRequiredColumn(String parent, String name, Type type, String doc); @Override UpdateSchema deleteColumn(String name); @Override UpdateSchema renameColumn(String name, String newName); @Override UpdateSchema requireColumn(String name); @Override UpdateSchema makeColumnOptional(String name); @Override UpdateSchema updateColumn(String name, Type.PrimitiveType newType); @Override UpdateSchema updateColumnDoc(String name, String doc); @Override UpdateSchema moveFirst(String name); @Override UpdateSchema moveBefore(String name, String beforeName); @Override UpdateSchema moveAfter(String name, String afterName); UpdateSchema updateSchema(Schema newSchema); @Override Schema apply(); @Override void commit(); }
SchemaUpdate implements UpdateSchema { private static List<Types.NestedField> addFields(List<Types.NestedField> fields, Collection<Types.NestedField> adds) { List<Types.NestedField> newFields = Lists.newArrayList(fields); newFields.addAll(adds); return newFields; } SchemaUpdate(TableOperations ops);   SchemaUpdate(Schema schema, int lastColumnId); @Override SchemaUpdate allowIncompatibleChanges(); @Override UpdateSchema addColumn(String name, Type type, String doc); @Override UpdateSchema addColumn(String parent, String name, Type type, String doc); @Override UpdateSchema addRequiredColumn(String name, Type type, String doc); @Override UpdateSchema addRequiredColumn(String parent, String name, Type type, String doc); @Override UpdateSchema deleteColumn(String name); @Override UpdateSchema renameColumn(String name, String newName); @Override UpdateSchema requireColumn(String name); @Override UpdateSchema makeColumnOptional(String name); @Override UpdateSchema updateColumn(String name, Type.PrimitiveType newType); @Override UpdateSchema updateColumnDoc(String name, String doc); @Override UpdateSchema moveFirst(String name); @Override UpdateSchema moveBefore(String name, String beforeName); @Override UpdateSchema moveAfter(String name, String afterName); UpdateSchema updateSchema(Schema newSchema); @Override Schema apply(); @Override void commit();  }