use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class SchemaDescriptorConverterTest method testConvert.
/**
* Test set of columns.
*
* @param nullable Nullable flag.
*/
private void testConvert(boolean nullable) {
TableDefinition tblSchm = getBuilder(nullable, true).build();
SchemaDescriptor tblDscr = SchemaDescriptorConverter.convert(1, tblSchm);
assertEquals(1, tblDscr.keyColumns().length());
testCol(tblDscr.keyColumns(), "ID", NativeTypeSpec.UUID, false);
assertEquals(columns - 1, tblDscr.valueColumns().length());
testCol(tblDscr.valueColumns(), "INT8", NativeTypeSpec.INT8, nullable);
testCol(tblDscr.valueColumns(), "INT16", NativeTypeSpec.INT16, nullable);
testCol(tblDscr.valueColumns(), "INT32", NativeTypeSpec.INT32, nullable);
testCol(tblDscr.valueColumns(), "INT64", NativeTypeSpec.INT64, nullable);
testCol(tblDscr.valueColumns(), "FLOAT", NativeTypeSpec.FLOAT, nullable);
testCol(tblDscr.valueColumns(), "DOUBLE", NativeTypeSpec.DOUBLE, nullable);
testCol(tblDscr.valueColumns(), "UUID", NativeTypeSpec.UUID, nullable);
testCol(tblDscr.valueColumns(), "STRING", NativeTypeSpec.STRING, nullable);
testCol(tblDscr.valueColumns(), "STRING_FS10", NativeTypeSpec.STRING, nullable);
testCol(tblDscr.valueColumns(), "BLOB", NativeTypeSpec.BYTES, nullable);
testCol(tblDscr.valueColumns(), "DECIMAL", NativeTypeSpec.DECIMAL, nullable);
testCol(tblDscr.valueColumns(), "NUMBER", NativeTypeSpec.NUMBER, nullable);
testCol(tblDscr.valueColumns(), "DECIMAL", NativeTypeSpec.DECIMAL, nullable);
testCol(tblDscr.valueColumns(), "BITMASK_FS10", NativeTypeSpec.BITMASK, nullable);
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class SchemaConfigurationTest method testSchemaModification.
/**
* TestSchemaModification.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@Test
public void testSchemaModification() {
final TableDefinition table = SchemaBuilders.tableBuilder("PUBLIC", "table1").columns(// Declaring columns in user order.
SchemaBuilders.column("id", ColumnType.INT64).build(), SchemaBuilders.column("name", ColumnType.string()).build()).withPrimaryKey("id").build();
table.toBuilder().addColumn(SchemaBuilders.column("firstName", ColumnType.string()).build()).addKeyColumn(// It looks safe to add non-affinity column to key.
SchemaBuilders.column("subId", ColumnType.string()).build()).alterColumn("firstName").withNewName("lastName").withNewDefault("ivanov").asNullable().convertTo(ColumnType.stringOf(100)).done().dropColumn(// Key column can't be dropped.
"name").addIndex(SchemaBuilders.sortedIndex("sortedIdx").addIndexColumn("subId").done().withHints(Map.of("INLINE_SIZE", "73")).build()).dropIndex("hash_idx").apply();
}
Aggregations