korlov42 commented on code in PR #1109:
URL: https://github.com/apache/ignite-3/pull/1109#discussion_r978310923


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/SchemaUtils.java:
##########
@@ -36,13 +34,11 @@ public class SchemaUtils {
      * Creates schema descriptor for the table with specified configuration.
      *
      * @param schemaVer Schema version.
-     * @param tblCfg    Table configuration.
+     * @param tableView    Table configuration.

Review Comment:
   fixed 



##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/ColumnTypeValidatorImpl.java:
##########
@@ -53,11 +50,81 @@ public void validate(ColumnTypeValidator annotation, 
ValidationContext<ColumnTyp
                 || newType.precision() != oldType.precision()
                 || newType.scale() != oldType.scale()
                 || newType.length() != oldType.length()) {
-            ctx.addIssue(new ValidationIssue(ctx.currentKey(), "Unsupported 
column type change: " + ctx.currentKey()));
+            ColumnView columnView = ctx.getNewOwner();
+
+            assert columnView != null;
+
+            ctx.addIssue(new ValidationIssue(columnView.name(), "Column type 
can't be changed"));
         }
 
     }
 
+    private void validateLength(ValidationContext<ColumnTypeView> ctx, 
ColumnTypeView typeView) {
+        switch (typeView.type()) {
+            case "STRING":
+            case "BYTES":
+            case "BITMASK":
+                if (typeView.length() <= 0) {
+                    ColumnView columnView = ctx.getNewOwner();
+
+                    assert columnView != null;
+
+                    ctx.addIssue(new ValidationIssue(columnView.name(), 
"Length must by positive"));

Review Comment:
   good catch!



##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/ColumnTypeValidatorImpl.java:
##########
@@ -53,11 +50,81 @@ public void validate(ColumnTypeValidator annotation, 
ValidationContext<ColumnTyp
                 || newType.precision() != oldType.precision()
                 || newType.scale() != oldType.scale()
                 || newType.length() != oldType.length()) {
-            ctx.addIssue(new ValidationIssue(ctx.currentKey(), "Unsupported 
column type change: " + ctx.currentKey()));
+            ColumnView columnView = ctx.getNewOwner();
+
+            assert columnView != null;
+
+            ctx.addIssue(new ValidationIssue(columnView.name(), "Column type 
can't be changed"));
         }
 
     }
 
+    private void validateLength(ValidationContext<ColumnTypeView> ctx, 
ColumnTypeView typeView) {
+        switch (typeView.type()) {
+            case "STRING":
+            case "BYTES":
+            case "BITMASK":
+                if (typeView.length() <= 0) {
+                    ColumnView columnView = ctx.getNewOwner();
+
+                    assert columnView != null;
+
+                    ctx.addIssue(new ValidationIssue(columnView.name(), 
"Length must by positive"));
+                }
+
+                break;
+            default:
+                // nothing to do
+                break;
+        }
+    }
+
+    private void validatePrecision(ValidationContext<ColumnTypeView> ctx, 
ColumnTypeView typeView) {
+        switch (typeView.type()) {
+            case "NUMBER":
+            case "DECIMAL":
+                if (typeView.precision() <= 0) {
+                    ColumnView columnView = ctx.getNewOwner();
+
+                    assert columnView != null;
+
+                    ctx.addIssue(new ValidationIssue(columnView.name(), 
"Precision must by positive"));

Review Comment:
   fixed



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