AMashenkov commented on code in PR #2485:
URL: https://github.com/apache/ignite-3/pull/2485#discussion_r1302922411
##########
modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogManagerValidationTest.java:
##########
@@ -550,6 +557,118 @@ void testValidateZoneNamesOnRenameZone() {
);
}
+ @Test
+ void testValidateTableNameOnIndexCreate() {
+ assertThat(
+
manager.createIndex(CreateHashIndexParams.builder().schemaName(DEFAULT_SCHEMA_NAME).indexName(INDEX_NAME).build()),
+ willThrowFast(CatalogValidationException.class, "Missing table
name")
+ );
+
+ assertThat(
+
manager.createIndex(CreateSortedIndexParams.builder().schemaName(DEFAULT_SCHEMA_NAME).indexName(INDEX_NAME).build()),
+ willThrowFast(CatalogValidationException.class, "Missing table
name")
+ );
+ }
+
+ @Test
+ void testValidateIndexNameOnIndexCreate() {
+ assertThat(
+
manager.createIndex(CreateHashIndexParams.builder().schemaName(DEFAULT_SCHEMA_NAME).tableName(TABLE_NAME).build()),
+ willThrowFast(CatalogValidationException.class, "Missing index
name")
+ );
+
+ assertThat(
+
manager.createIndex(CreateSortedIndexParams.builder().schemaName(DEFAULT_SCHEMA_NAME).tableName(TABLE_NAME).build()),
+ willThrowFast(CatalogValidationException.class, "Missing index
name")
+ );
+ }
+
+ @Test
+ void testValidateIndexColumnsNotSpecifiedOnIndexCreate() {
+ assertThat(
+ manager.createIndex(createHashIndexParams(INDEX_NAME, null)),
+ willThrowFast(CatalogValidationException.class, "Columns not
specified")
+ );
+
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME, null,
null)),
+ willThrowFast(CatalogValidationException.class, "Columns not
specified")
+ );
+
+ assertThat(
+ manager.createIndex(createHashIndexParams(INDEX_NAME,
List.of())),
+ willThrowFast(CatalogValidationException.class, "Columns not
specified")
+ );
+
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
List.of(), null)),
+ willThrowFast(CatalogValidationException.class, "Columns not
specified")
+ );
+ }
+
+ @Test
+ void testValidateIndexColumnsContainsNullOnIndexCreate() {
+ assertThat(
+ manager.createIndex(createHashIndexParams(INDEX_NAME,
Arrays.asList("key", null))),
+ willThrowFast(CatalogValidationException.class, "One of the
columns is null")
+ );
+
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
Arrays.asList("key", null), null)),
+ willThrowFast(CatalogValidationException.class, "One of the
columns is null")
+ );
+ }
+
+ @Test
+ void testValidateIndexColumnsDuplicatesOnIndexCreate() {
+ assertThat(
+ manager.createIndex(createHashIndexParams(INDEX_NAME,
Arrays.asList("key", "key"))),
+ willThrowFast(CatalogValidationException.class, "Duplicate
columns are present")
+ );
+
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
Arrays.asList("key", "key"), null)),
+ willThrowFast(CatalogValidationException.class, "Duplicate
columns are present")
+ );
+ }
+
+ @Test
+ void testValidateIndexColumnsCollationsNotSpecifiedOnIndexCreate() {
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
List.of("key"), null)),
+ willThrowFast(CatalogValidationException.class, "Columns
collations not specified")
+ );
+
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
List.of("key"), List.of())),
+ willThrowFast(CatalogValidationException.class, "Columns
collations not specified")
+ );
+ }
+
+ @Test
+ void testValidateIndexColumnsCollationsContainsNullOnIndexCreate() {
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
List.of("key", "val"), Arrays.asList(ASC_NULLS_FIRST, null))),
+ willThrowFast(CatalogValidationException.class, "One of the
columns collations is null")
+ );
+ }
+
+ @Test
+ void
testValidateIndexColumnsCollationsNotScameSizeWithColumnsOnIndexCreate() {
+ assertThat(
+ manager.createIndex(createSortedIndexParams(INDEX_NAME,
Arrays.asList("key", "val"), List.of(ASC_NULLS_FIRST))),
+ willThrowFast(CatalogValidationException.class, "Columns
collations doesn't match number of columns")
+ );
Review Comment:
```suggestion
);
assertThat(
manager.createIndex(createSortedIndexParams(INDEX_NAME,
Arrays.asList("key"), List.of(ASC_NULLS_FIRST, ASC_NULLS_FIRST))),
willThrowFast(CatalogValidationException.class, "Columns
collations doesn't match number of columns")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]