AMashenkov commented on code in PR #3501:
URL: https://github.com/apache/ignite-3/pull/3501#discussion_r1542677428


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/TablePrimaryKey.java:
##########
@@ -44,16 +45,27 @@ public List<String> columns() {
     }
 
     /** Performs additional validation of this primary key. */
-    void validate(Set<String> allColumns) {
-        Set<String> columnSet = new HashSet<>();
+    void validate(List<ColumnParams> allColumns) {
+        Set<String> allColumnNames = new HashSet<>(allColumns.size());
+        for (ColumnParams column : allColumns) {
+            allColumnNames.add(column.name());
 
-        for (String name : columns) {
-            if (!allColumns.contains(name)) {
-                throw new CatalogValidationException(format("PK column '{}' is 
not part of table", name));
+            boolean partOfPk = columns.contains(column.name());
+            if (partOfPk && column.nullable()) {
+                throw new CatalogValidationException(format("Primary key 
cannot contain nullable column [col={}].", column.name()));
             }
+        }
 
+        List<String> columnsNotInTable = columns.stream().filter(n -> 
!allColumnNames.contains(n)).collect(Collectors.toList());

Review Comment:
   ```suggestion
           List<String> columnsNotInTable = columns.stream()
               .filter(Predicate.not(allColumnNames::contains))
               .collect(Collectors.toList());
   ```



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