Search in sources :

Example 36 with TableDefinition

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);
}
Also used : SchemaDescriptor(org.apache.ignite.internal.schema.SchemaDescriptor) TableDefinition(org.apache.ignite.schema.definition.TableDefinition)

Example 37 with TableDefinition

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();
}
Also used : TableDefinition(org.apache.ignite.schema.definition.TableDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

TableDefinition (org.apache.ignite.schema.definition.TableDefinition)37 Test (org.junit.jupiter.api.Test)25 Table (org.apache.ignite.table.Table)14 List (java.util.List)11 SchemaBuilders (org.apache.ignite.schema.SchemaBuilders)11 ColumnType (org.apache.ignite.schema.definition.ColumnType)11 Disabled (org.junit.jupiter.api.Disabled)11 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)10 Collection (java.util.Collection)9 TableDefinitionBuilder (org.apache.ignite.schema.definition.builder.TableDefinitionBuilder)9 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)9 Collections (java.util.Collections)8 DataStorageConfiguration (org.apache.ignite.configuration.schemas.store.DataStorageConfiguration)8 RocksDbDataRegionConfigurationSchema (org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema)8 HashIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema)8 PartialIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema)8 SortedIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema)8 TablesConfiguration (org.apache.ignite.configuration.schemas.table.TablesConfiguration)8 AfterEach (org.junit.jupiter.api.AfterEach)8 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)8