use of org.apache.ignite.schema.definition.index.IndexColumnDefinition in project ignite-3 by apache.
the class SchemaConfigurationConverterTest method testUniqIndex.
/**
* Add/remove index on primary key into configuration and read it back.
*/
@Test
public void testUniqIndex() throws Exception {
SortedIndexDefinition idx = SchemaBuilders.sortedIndex("pk_sorted").addIndexColumn("COL1").desc().done().unique(true).build();
getTbl().change(ch -> SchemaConfigurationConverter.addIndex(idx, ch)).get();
TableDefinition tbl = SchemaConfigurationConverter.convert(getTbl().value());
SortedIndexDefinition idx2 = (SortedIndexDefinition) getIdx(idx.name(), tbl.indices());
assertNotNull(idx2);
assertEquals("PK_SORTED", idx2.name());
assertEquals("SORTED", idx2.type());
assertEquals(idx.columns().stream().map(IndexColumnDefinition::name).collect(Collectors.toList()), idx2.columns().stream().map(IndexColumnDefinition::name).collect(Collectors.toList()));
assertTrue(idx2.unique());
}
Aggregations