tkalkirill commented on code in PR #2493:
URL: https://github.com/apache/ignite-3/pull/2493#discussion_r1305328574


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogParamsValidationUtils.java:
##########
@@ -206,25 +295,68 @@ private static void 
validateCommonCreateIndexParams(AbstractCreateIndexCommandPa
 
         validateNameField(params.tableName(), 
Index.INVALID_INDEX_DEFINITION_ERR, "Missing table name");
 
-        if (CollectionUtils.nullOrEmpty(params.columns())) {
-            throw new 
CatalogValidationException(Index.INVALID_INDEX_DEFINITION_ERR, "Columns not 
specified");
-        }
-
-        params.columns().stream()
-                .filter(Predicate.not(new HashSet<>()::add))
-                .findAny()
-                .ifPresent(columnName -> {
-                    throw new CatalogValidationException(
-                            Index.INVALID_INDEX_DEFINITION_ERR,
-                            "Duplicate columns are present: {}",
-                            params.columns()
-                    );
-                });
+        validateColumns(
+                params.columns(),
+                Index.INVALID_INDEX_DEFINITION_ERR,
+                "Columns not specified",
+                "Duplicate columns are present: {}"
+        );
     }
 
     private static void validateNameField(String name, int errorCode, String 
errorMessage) {
         if (StringUtils.nullOrBlank(name)) {
             throw new CatalogValidationException(errorCode, errorMessage);
         }
     }
+
+    private static void validateCollectionIsNotEmpty(Collection<?> collection, 
int errorCode, String errorMessage) {
+        if (CollectionUtils.nullOrEmpty(collection)) {
+            throw new CatalogValidationException(errorCode, errorMessage);
+        }
+    }
+
+    private static void validateColumns(
+            List<String> columns,
+            int errorCode,
+            String emptyColumnsErrorMessage,
+            String duplicateColumnsErrorMessageFormat
+    ) {
+        validateCollectionIsNotEmpty(columns, errorCode, 
emptyColumnsErrorMessage);
+
+        List<String> duplicates = columns.stream()
+                .filter(Predicate.not(new HashSet<>()::add))
+                .collect(toList());
+
+        if (!duplicates.isEmpty()) {
+            throw new CatalogValidationException(errorCode, 
duplicateColumnsErrorMessageFormat, duplicates);
+        }
+    }
+
+    private static void validateColumnsContainsInAnotherColumns(
+            List<String> columns,

Review Comment:
   fix it



-- 
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]

Reply via email to