zstan commented on a change in pull request #441:
URL: https://github.com/apache/ignite-3/pull/441#discussion_r752231665



##########
File path: 
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTablesApiTest.java
##########
@@ -204,12 +425,135 @@ public void testCreateDropTable() throws Exception {
      */
     protected Table createTable(Ignite node, String schemaName, String 
shortTableName) {
         return node.tables().createTable(
-                schemaName + "." + shortTableName, tblCh -> 
convert(SchemaBuilders.tableBuilder(schemaName, shortTableName).columns(
-                                SchemaBuilders.column("key", 
ColumnType.INT64).asNonNull().build(),
-                                SchemaBuilders.column("valInt", 
ColumnType.INT32).asNullable().build(),
-                                SchemaBuilders.column("valStr", 
ColumnType.string()).withDefaultValueExpression("default").build()
+                schemaName + "." + shortTableName,
+                tblCh -> convert(SchemaBuilders.tableBuilder(schemaName, 
shortTableName).columns(
+                        SchemaBuilders.column("key", 
ColumnType.INT64).asNonNull().build(),
+                        SchemaBuilders.column("valInt", 
ColumnType.INT32).asNullable().build(),
+                        SchemaBuilders.column("valStr", ColumnType.string())
+                                .withDefaultValueExpression("default").build()
+                        ).withPrimaryKey("key").build(),
+                        tblCh).changeReplicas(2).changePartitions(10)
+        );
+    }
+    
+    /**
+     * Adds an index if it does not exist.
+     *
+     * @param node           Cluster node.
+     * @param schemaName     Schema name.
+     * @param shortTableName Table name.
+     */
+    protected Table createTableIfNotExists(Ignite node, String schemaName, 
String shortTableName) {
+        return node.tables().createTableIfNotExists(
+                schemaName + "." + shortTableName,
+                tblCh -> convert(SchemaBuilders.tableBuilder(schemaName, 
shortTableName).columns(
+                        SchemaBuilders.column("key", 
ColumnType.INT64).asNonNull().build(),
+                        SchemaBuilders.column("valInt", 
ColumnType.INT32).asNullable().build(),
+                        SchemaBuilders.column("valStr", ColumnType.string())
+                                .withDefaultValueExpression("default").build()
                         ).withPrimaryKey("key").build(),
                         tblCh).changeReplicas(2).changePartitions(10)
         );
     }
+    
+    /**
+     * Adds an index.
+     *
+     * @param node           Cluster node.
+     * @param schemaName     Schema name.
+     * @param shortTableName Table name.
+     */
+    protected void addColumn(Ignite node, String schemaName, String 
shortTableName) {
+        ColumnDefinition col = SchemaBuilders.column("valStrNew", 
ColumnType.string()).asNullable()
+                .withDefaultValueExpression("default").build();
+    
+        addColumnInternal(node, schemaName, shortTableName, col);
+    }
+    
+    /**
+     * Adds a column according to the column definition.
+     *
+     * @param node Ignite node.
+     * @param schemaName Schema name.
+     * @param shortTableName Table name.
+     * @param colDefinition Column defenition.
+     */
+    private void addColumnInternal(Ignite node, String schemaName, String 
shortTableName, ColumnDefinition colDefinition) {
+        node.tables().alterTable(
+                schemaName + "." + shortTableName,

Review comment:
       can we make utility method instead numerous : schemaName + "." + 
shortTableName ?




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