You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/24 12:48:23 UTC

[GitHub] [ignite-3] AMashenkov opened a new pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

AMashenkov opened a new pull request #360:
URL: https://github.com/apache/ignite-3/pull/360


   https://issues.apache.org/jira/browse/IGNITE-15414


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] ygerzhedovich commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
ygerzhedovich commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r736598382



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/ColumnTypeValidatorImpl.java
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema.configuration;
+
+import java.util.Objects;
+import org.apache.ignite.configuration.schemas.table.ColumnTypeValidator;
+import org.apache.ignite.configuration.schemas.table.ColumnTypeView;
+import org.apache.ignite.configuration.validation.ValidationContext;
+import org.apache.ignite.configuration.validation.ValidationIssue;
+import org.apache.ignite.configuration.validation.Validator;
+
+/**
+ * Column definition validator implementation validates column changes.
+ */
+public class ColumnTypeValidatorImpl implements Validator<ColumnTypeValidator, ColumnTypeView> {
+    /** Static instance. */
+    public static final ColumnTypeValidatorImpl INSTANCE = new ColumnTypeValidatorImpl();
+
+    /** {@inheritDoc} */
+    @Override public void validate(ColumnTypeValidator annotation, ValidationContext<ColumnTypeView> ctx) {
+        ColumnTypeView newType = ctx.getNewValue();
+        ColumnTypeView oldType = ctx.getOldValue();
+
+        try {
+            SchemaConfigurationConverter.convert(newType);
+        } catch (IllegalArgumentException ex) {
+            ctx.addIssue(new ValidationIssue(ctx.currentKey() + ": " + ex.getMessage()));
+
+            return;
+        }
+
+        if (oldType == null)
+            return; // Nothing to do.
+
+        if (!Objects.deepEquals(newType.type(), oldType.type()) ||
+                newType.precision() != oldType.precision() ||
+                newType.scale() != oldType.scale() ||
+                newType.length() != oldType.length())

Review comment:
       so, is it mean that right now we don't support conversion at all?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] Berkof commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
Berkof commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731533379



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -981,6 +1006,23 @@ private boolean isTableConfigured(String name) {
         return tableNamesConfigured().contains(name);
     }
 
+    /**
+     * Join and unwrap {@link CompletionException} to {@link IgniteException} if needed.
+     *
+     * @param future Completable future.
+     */
+    private void join(CompletableFuture<Void> future) {
+        try {
+            future.join();
+        }
+        catch (CompletionException ex) {

Review comment:
       "catch (RuntimeException e)" ?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] Berkof commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
Berkof commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731529915



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
##########
@@ -252,4 +264,120 @@ void testDynamicTableCreation() {
         assertEquals(7373, (Integer)kvView2.get(keyTuple2).value("valInt"));
         assertNull(kvView2.get(keyTuple2).value("valNull"));
     }
+
+    /**
+     * Check unsupported column type change.
+     */
+    @Test
+    public void testChangeColumnType() {
+        List<Ignite> grid = startGrid();
+
+        assertTableCreationFailed(grid, c -> c.changeType(t -> t.changeType("UNKNOWN_TYPE")));
+
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("STRING").changeLength(-1)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("BYTES").changeLength(-1)));
+
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("INT32").changePrecision(-1)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("INT32").changeScale(-1)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("BYTES").changeLength(-1)));
+
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("NUMBER").changePrecision(-1)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("NUMBER").changeScale(-2)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("BYTES").changeLength(-1)));
+
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(c -> c.changeType("DECIMAL").changePrecision(-1)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(c -> c.changeType("DECIMAL").changePrecision(0)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(c -> c.changeType("DECIMAL").changeScale(-2)));
+        assertTableCreationFailed(grid, colChanger -> colChanger.changeType(t -> t.changeType("BYTES").changeLength(-1)));
+    }
+
+    @Disabled("IGNITE-15747")

Review comment:
       ```suggestion
       @Disabled("https://issues.apache.org/jira/browse/IGNITE-15747")
   ```




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731608890



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
##########
@@ -120,16 +127,25 @@ void tearDown() throws Exception {
     }
 
     /**
-     * Check dynamic table creation.
+     * @return Grid nodes.
      */
-    @Test
-    void testDynamicSimpleTableCreation() {
+    @NotNull protected List<Ignite> startGrid() {

Review comment:
       There are number of tests that start the grid, so it make sense to move startGrid() function to a higher level e.g. to a new ITIgniteAbstractTest that extends IgniteAbstractTest.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vladErmakov07 commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
vladErmakov07 commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731095439



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
##########
@@ -120,16 +127,25 @@ void tearDown() throws Exception {
     }
 
     /**
-     * Check dynamic table creation.
+     * @return Grid nodes.
      */
-    @Test
-    void testDynamicSimpleTableCreation() {
+    @NotNull protected List<Ignite> startGrid() {

Review comment:
       I suggest inheriting this class from AbstractSchemaChangeTest. As I see, we can simply use AbstractSchemaChangeTest#startGrid function.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vladErmakov07 commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
vladErmakov07 commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731100241



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java
##########
@@ -123,85 +124,44 @@ void afterEach() throws Exception {
     /**
      * Check unsupported column type change.
      */
-    @Disabled("https://issues.apache.org/jira/browse/IGNITE-15056")
     @Test
     public void testChangeColumnType() {

Review comment:
       Maybe we should create a non-abstract class for these tests? 
   It's a bit strange to keep them next to utility functionality like starting\stopping nodes.
   




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r740182160



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/ColumnTypeValidatorImpl.java
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema.configuration;
+
+import java.util.Objects;
+import org.apache.ignite.configuration.schemas.table.ColumnTypeValidator;
+import org.apache.ignite.configuration.schemas.table.ColumnTypeView;
+import org.apache.ignite.configuration.validation.ValidationContext;
+import org.apache.ignite.configuration.validation.ValidationIssue;
+import org.apache.ignite.configuration.validation.Validator;
+
+/**
+ * Column definition validator implementation validates column changes.
+ */
+public class ColumnTypeValidatorImpl implements Validator<ColumnTypeValidator, ColumnTypeView> {
+    /** Static instance. */
+    public static final ColumnTypeValidatorImpl INSTANCE = new ColumnTypeValidatorImpl();
+
+    /** {@inheritDoc} */
+    @Override public void validate(ColumnTypeValidator annotation, ValidationContext<ColumnTypeView> ctx) {
+        ColumnTypeView newType = ctx.getNewValue();
+        ColumnTypeView oldType = ctx.getOldValue();
+
+        try {
+            SchemaConfigurationConverter.convert(newType);
+        } catch (IllegalArgumentException ex) {
+            ctx.addIssue(new ValidationIssue(ctx.currentKey() + ": " + ex.getMessage()));
+
+            return;
+        }
+
+        if (oldType == null)
+            return; // Nothing to do.
+
+        if (!Objects.deepEquals(newType.type(), oldType.type()) ||
+                newType.precision() != oldType.precision() ||
+                newType.scale() != oldType.scale() ||
+                newType.length() != oldType.length())

Review comment:
       Yes, conversion is not supported.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov merged pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
AMashenkov merged pull request #360:
URL: https://github.com/apache/ignite-3/pull/360


   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731613590



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITDynamicTableCreationTest.java
##########
@@ -120,16 +127,25 @@ void tearDown() throws Exception {
     }
 
     /**
-     * Check dynamic table creation.
+     * @return Grid nodes.
      */
-    @Test
-    void testDynamicSimpleTableCreation() {
+    @NotNull protected List<Ignite> startGrid() {

Review comment:
       I've created a ticket for this.
   https://issues.apache.org/jira/browse/IGNITE-15772




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731617934



##########
File path: modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java
##########
@@ -123,85 +124,44 @@ void afterEach() throws Exception {
     /**
      * Check unsupported column type change.
      */
-    @Disabled("https://issues.apache.org/jira/browse/IGNITE-15056")
     @Test
     public void testChangeColumnType() {

Review comment:
       1. For now, we must be sure both schema management modes have this behavior.
   2. Later, we may implement extended capabilities and will fix or move these tests.
   




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] vladErmakov07 commented on a change in pull request #360: IGNITE-15414 Schema validation refactoring with configuration validators

Posted by GitBox <gi...@apache.org>.
vladErmakov07 commented on a change in pull request #360:
URL: https://github.com/apache/ignite-3/pull/360#discussion_r731086863



##########
File path: modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
##########
@@ -179,12 +180,15 @@
 
         // TODO: IGNITE-15414 Schema validation refactoring with configuration validators.

Review comment:
       Do we still need this TODO comment?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org