/** * Add a new column that's not nullable. * @param name name of the new column * @param type type of the new column * @param defaultVal default value used for the currently existing rows * @return this instance */ public AlterTableOptions addColumn(String name, Type type, Object defaultVal) { return addColumn(new ColumnSchema.ColumnSchemaBuilder(name, type) .defaultValue(defaultVal) .build()); }
/** * Add a new column that's nullable. * @param name name of the new column * @param type type of the new column * @param defaultVal the default value of the new column * @return this instance */ public AlterTableOptions addNullableColumn(String name, Type type, Object defaultVal) { return addColumn(new ColumnSchema.ColumnSchemaBuilder(name, type) .nullable(true) .defaultValue(defaultVal) .build()); }
.addColumn("addNonNull", Type.INT32, 100) .addNullableColumn("addNullable", Type.INT32) .addNullableColumn("addNullableDef", Type.INT32, 200));
new AlterTableOptions().addColumn( new ColumnSchema.ColumnSchemaBuilder("a", Type.STRING).nullable(true).build())); try { testTableName, new AlterTableOptions().dropColumn("a") .addColumn(new ColumnSchema.ColumnSchemaBuilder("a", Type.INT64) .nullable(true).build())); try { testTableName, new AlterTableOptions().dropColumn("a") .addColumn(new ColumnSchema.ColumnSchemaBuilder("a", Type.INT64) .nullable(false) .defaultValue(0L).build()));