ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-5326, IGNITE-5328: Added CREATE TABLE params for backups number and atomicity mode. This closes #2054.
Date Fri, 02 Jun 2017 12:26:14 GMT
Repository: ignite
Updated Branches:
  refs/heads/master a93af2956 -> bfb278154


IGNITE-5326, IGNITE-5328: Added CREATE TABLE params for backups number and atomicity mode.
This closes #2054.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bfb27815
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bfb27815
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bfb27815

Branch: refs/heads/master
Commit: bfb278154b27cc968ad816eb7fadbe61f2a228ab
Parents: a93af29
Author: Alexander Paschenko <alexander.a.paschenko@gmail.com>
Authored: Fri Jun 2 15:26:07 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Fri Jun 2 15:26:07 2017 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    | 25 ++++--
 .../query/h2/ddl/DdlStatementsProcessor.java    |  7 +-
 .../query/h2/sql/GridSqlCreateTable.java        | 48 ++++++++--
 .../query/h2/sql/GridSqlQueryParser.java        | 94 ++++++++++++++++----
 .../cache/index/H2DynamicTableSelfTest.java     | 76 ++++++++++++++--
 .../query/h2/sql/GridQueryParsingTest.java      | 24 ++---
 6 files changed, 219 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb27815/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index ea8f890..1c1fa34 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
@@ -1277,24 +1278,34 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      *
      * @param schemaName Schema name to create table in.
      * @param entity Entity to create table from.
-     * @param templateCacheName Cache name to take settings from.
+     * @param templateName Template name.
+     * @param atomicityMode Atomicity mode.
+     * @param backups Backups.
      * @param ifNotExists Quietly ignore this command if table already exists.
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("unchecked")
-    public void dynamicTableCreate(String schemaName, QueryEntity entity, String templateCacheName,
boolean ifNotExists)
-        throws IgniteCheckedException {
-        CacheConfiguration<?, ?> templateCfg = ctx.cache().getConfigFromTemplate(templateCacheName);
+    public void dynamicTableCreate(String schemaName, QueryEntity entity, String templateName,
+        @Nullable CacheAtomicityMode atomicityMode, int backups, boolean ifNotExists) throws
IgniteCheckedException {
+        assert !F.isEmpty(templateName);
+        assert backups >= 0;
+
+        CacheConfiguration<?, ?> templateCfg = ctx.cache().getConfigFromTemplate(templateName);
 
         if (templateCfg == null)
-            throw new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND,
templateCacheName);
+            throw new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND,
templateName);
 
         if (!F.isEmpty(templateCfg.getQueryEntities()))
-            throw new SchemaOperationException("Template cache already contains query entities
which it should not " +
-                "[cacheName=" + templateCacheName + ']');
+            throw new SchemaOperationException("Template cannot contain query entities [template="
+
+                templateName + ']');
 
         CacheConfiguration<?, ?> newCfg = new CacheConfiguration<>(templateCfg);
 
+        if (atomicityMode != null)
+            newCfg.setAtomicityMode(atomicityMode);
+
+        newCfg.setBackups(backups);
+
         newCfg.setName(entity.getTableName());
         newCfg.setQueryEntities(Collections.singleton(entity));
         newCfg.setSqlSchema(schemaName);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb27815/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
index d278e37..c9e3295 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
@@ -161,9 +161,10 @@ public class DdlStatementsProcessor {
                         throw new SchemaOperationException(SchemaOperationException.CODE_TABLE_EXISTS,
                             cmd.tableName());
                 }
-                else
-                    ctx.query().dynamicTableCreate(cmd.schemaName(), toQueryEntity(cmd),
cmd.templateCacheName(),
-                        cmd.ifNotExists());
+                else {
+                    ctx.query().dynamicTableCreate(cmd.schemaName(), toQueryEntity(cmd),
cmd.templateName(),
+                        cmd.atomicityMode(), cmd.backups(), cmd.ifNotExists());
+                }
             }
             else if (stmt0 instanceof GridSqlDropTable) {
                 GridSqlDropTable cmd = (GridSqlDropTable)stmt0;

http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb27815/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
index 52c9cc9..50348fe 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlCreateTable.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.query.h2.sql;
 
+import org.apache.ignite.cache.CacheAtomicityMode;
+
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -34,7 +36,13 @@ public class GridSqlCreateTable extends GridSqlStatement {
     private String tblName;
 
     /** Cache name upon which new cache configuration for this table must be based. */
-    private String tplCacheName;
+    private String templateName;
+
+    /** Atomicity mode for new cache. */
+    private CacheAtomicityMode atomicityMode;
+
+    /** Backups number for new cache. */
+    private int backups;
 
     /** Quietly ignore this command if table already exists. */
     private boolean ifNotExists;
@@ -51,15 +59,43 @@ public class GridSqlCreateTable extends GridSqlStatement {
     /**
      * @return Cache name upon which new cache configuration for this table must be based.
      */
-    public String templateCacheName() {
-        return tplCacheName;
+    public String templateName() {
+        return templateName;
+    }
+
+    /**
+     * @param templateName Cache name upon which new cache configuration for this table must
be based.
+     */
+    public void templateName(String templateName) {
+        this.templateName = templateName;
+    }
+
+    /**
+     * @return Atomicity mode for new cache.
+     */
+    public CacheAtomicityMode atomicityMode() {
+        return atomicityMode;
+    }
+
+    /**
+     * @param atomicityMode Atomicity mode for new cache.
+     */
+    public void atomicityMode(CacheAtomicityMode atomicityMode) {
+        this.atomicityMode = atomicityMode;
+    }
+
+    /**
+     * @return Backups number for new cache.
+     */
+    public int backups() {
+        return backups;
     }
 
     /**
-     * @param tplCacheName Cache name upon which new cache configuration for this table must
be based.
+     * @param backups Backups number for new cache.
      */
-    public void templateCacheName(String tplCacheName) {
-        this.tplCacheName = tplCacheName;
+    public void backups(int backups) {
+        this.backups = backups;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb27815/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
index f310e0f..573384a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java
@@ -29,6 +29,8 @@ import java.util.List;
 import java.util.Map;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
 import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
@@ -395,11 +397,17 @@ public class GridSqlQueryParser {
     private static final String PARAM_NAME_VALUE_SEPARATOR = "=";
 
     /** */
-    private static final String PARAM_CACHE_TEMPLATE = "cacheTemplate";
+    private static final String PARAM_TEMPLATE = "TEMPLATE";
+
+    /** */
+    private static final String PARAM_BACKUPS = "BACKUPS";
+
+    /** */
+    private static final String PARAM_ATOMICITY = "ATOMICITY";
 
     /** Names of the params that need to be present in WITH clause of CREATE TABLE. */
     private static final String[] MANDATORY_CREATE_TABLE_PARAMS = {
-        PARAM_CACHE_TEMPLATE
+        PARAM_TEMPLATE
     };
 
     /** */
@@ -944,7 +952,11 @@ public class GridSqlQueryParser {
 
         res.ifNotExists(CREATE_TABLE_IF_NOT_EXISTS.get(createTbl));
 
-        List<String> extraParams = data.tableEngineParams;
+        List<String> extraParams = data.tableEngineParams != null ? new ArrayList<String>()
: null;
+
+        if (data.tableEngineParams != null)
+            for (String s : data.tableEngineParams)
+                extraParams.addAll(F.asList(s.split(",")));
 
         res.params(extraParams);
 
@@ -955,24 +967,26 @@ public class GridSqlQueryParser {
                 String[] parts = p.split(PARAM_NAME_VALUE_SEPARATOR);
 
                 if (parts.length > 2)
-                    throw new IgniteSQLException("Invalid param syntax: key[=value] expected
[paramStr=" + p + ']',
+                    throw new IgniteSQLException("Invalid parameter (key[=value] expected):
" + p,
                         IgniteQueryErrorCode.PARSING);
 
-                String name = parts[0];
+                String name = parts[0].trim().toUpperCase();
 
-                String val = parts.length > 1 ? parts[1] : null;
+                String val = parts.length > 1 ? parts[1].trim() : null;
 
                 if (F.isEmpty(name))
-                    throw new IgniteSQLException("Invalid param syntax: no name given [paramStr="
+ p + ']',
+                    throw new IgniteSQLException("Invalid parameter (key[=value] expected):
" + p,
                         IgniteQueryErrorCode.PARSING);
 
-                params.put(name, val);
+                if (params.put(name, val) != null)
+                    throw new IgniteSQLException("Duplicate parameter: " + p, IgniteQueryErrorCode.PARSING);
             }
         }
 
-        for (String mandParamName : MANDATORY_CREATE_TABLE_PARAMS) {
-            if (!params.containsKey(mandParamName))
-                throw new IgniteSQLException("Mandatory param is missing [paramName=" + mandParamName
+ ']');
+        for (String paramName : MANDATORY_CREATE_TABLE_PARAMS) {
+            if (!params.containsKey(paramName))
+                throw new IgniteSQLException("Mandatory parameter is missing: " + paramName,
+                    IgniteQueryErrorCode.PARSING);
         }
 
         for (Map.Entry<String, String> e : params.entrySet())
@@ -1010,16 +1024,45 @@ public class GridSqlQueryParser {
         assert !F.isEmpty(name);
 
         switch (name) {
-            case PARAM_CACHE_TEMPLATE:
-                ensureParamValueNotEmpty(PARAM_CACHE_TEMPLATE, val);
+            case PARAM_TEMPLATE:
+                ensureNotEmpty(name, val);
+
+                res.templateName(val);
 
-                res.templateCacheName(val);
+                break;
+
+            case PARAM_BACKUPS:
+                ensureNotEmpty(name, val);
+
+                int backups = parseIntParam(PARAM_BACKUPS, val);
+
+                if (backups < 0)
+                    throw new IgniteSQLException("\"" + PARAM_BACKUPS + "\" cannot be negative:
" + backups,
+                        IgniteQueryErrorCode.PARSING);
+
+                res.backups(backups);
+
+                break;
+
+            case PARAM_ATOMICITY:
+                ensureNotEmpty(name, val);
+
+                CacheAtomicityMode mode;
+
+                if (CacheAtomicityMode.TRANSACTIONAL.name().equalsIgnoreCase(val))
+                    mode = CacheAtomicityMode.TRANSACTIONAL;
+                else if (CacheAtomicityMode.ATOMIC.name().equalsIgnoreCase(val))
+                    mode = CacheAtomicityMode.ATOMIC;
+                else
+                    throw new IgniteSQLException("Invalid value of \"" + PARAM_ATOMICITY
+ "\" parameter " +
+                        "(should be either TRANSACTIONAL or ATOMIC): " + val, IgniteQueryErrorCode.PARSING);
+
+                res.atomicityMode(mode);
 
                 break;
 
             default:
-                throw new IgniteSQLException("Unknown CREATE TABLE param [paramName=" + name
+ ']',
-                    IgniteQueryErrorCode.PARSING);
+                throw new IgniteSQLException("Unsupported parameter: " + name, IgniteQueryErrorCode.PARSING);
         }
     }
 
@@ -1028,10 +1071,25 @@ public class GridSqlQueryParser {
      * @param name Param name.
      * @param val Param value to check.
      */
-    private static void ensureParamValueNotEmpty(String name, String val) {
+    private static void ensureNotEmpty(String name, String val) {
         if (F.isEmpty(val))
-            throw new IgniteSQLException("No value has been given for a CREATE TABLE param
[paramName=" + name + ']',
+            throw new IgniteSQLException("Parameter value cannot be empty: " + name, IgniteQueryErrorCode.PARSING);
+    }
+
+    /**
+     * Parse given value as integer, or throw an {@link IgniteSQLException} if it's not of
matching format.
+     * @param name param name.
+     * @param val param value.
+     * @return parsed int value.
+     */
+    private static int parseIntParam(String name, String val) {
+        try {
+            return Integer.parseInt(val);
+        }
+        catch (NumberFormatException e) {
+            throw new IgniteSQLException("Parameter value must be an integer [name=" + name
+ ", value=" + val + ']',
                 IgniteQueryErrorCode.PARSING);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb27815/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
index 6f0dec6..b43d3f2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
@@ -99,7 +99,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     public void testCreateTable() throws Exception {
         executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," +
             " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
-            "\"cacheTemplate=cache\"");
+            "\"template=cache,backups=10\",\"atomicity=atomic\"");
 
         for (int i = 0; i < 4; i++) {
             IgniteEx node = grid(i);
@@ -110,6 +110,10 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
 
             assertNotNull(cacheDesc);
 
+            assertEquals(10, cacheDesc.cacheConfiguration().getBackups());
+
+            assertEquals(CacheAtomicityMode.ATOMIC, cacheDesc.cacheConfiguration().getAtomicityMode());
+
             assertTrue(cacheDesc.sql());
 
             QueryTypeDescriptorImpl desc = typeExisting(node, "Person", "Person");
@@ -144,6 +148,35 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
+     * Test that attempting to specify negative number of backups yields exception.
+     */
+    public void testNegativeBackups() {
+        assertCreateTableWithParamsThrows("bAckUPs = -5  ", "\"BACKUPS\" cannot be negative:
-5");
+    }
+
+    /**
+     * Test that attempting to omit mandatory value of BACKUPS parameter yields an error.
+     */
+    public void testEmptyBackups() {
+        assertCreateTableWithParamsThrows(" bAckUPs =  ", "Parameter value cannot be empty:
BACKUPS");
+    }
+
+    /**
+     * Test that attempting to omit mandatory value of ATOMICITY parameter yields an error.
+     */
+    public void testEmptyAtomicity() {
+        assertCreateTableWithParamsThrows("AtomicitY=  ", "Parameter value cannot be empty:
ATOMICITY");
+    }
+
+    /**
+     * Test that attempting to omit mandatory value of ATOMICITY parameter yields an error.
+     */
+    public void testInvalidAtomicity() {
+        assertCreateTableWithParamsThrows("atomicity=InvalidValue",
+            "Invalid value of \"ATOMICITY\" parameter (should be either TRANSACTIONAL or
ATOMIC): InvalidValue");
+    }
+
+    /**
      * Test that attempting to {@code CREATE TABLE} that already exists does not yield an
error if the statement
      *     contains {@code IF NOT EXISTS} clause.
      * @throws Exception if failed.
@@ -151,11 +184,11 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     public void testCreateTableIfNotExists() throws Exception {
         executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," +
             " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
-            "\"cacheTemplate=cache\"");
+            "\"template=cache\"");
 
         executeDdl("CREATE TABLE IF NOT EXISTS \"Person\" (\"id\" int, \"city\" varchar,"
+
             " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
-            "\"cacheTemplate=cache\"");
+            "\"template=cache\"");
     }
 
     /**
@@ -166,13 +199,13 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     public void testCreateExistingTable() throws Exception {
         executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," +
             " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
-            "\"cacheTemplate=cache\"");
+            "\"template=cache\"");
 
         GridTestUtils.assertThrows(null, new Callable<Object>() {
             @Override public Object call() throws Exception {
                 executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar" +
                     ", \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\",
\"city\")) WITH " +
-                    "\"cacheTemplate=cache\"");
+                    "\"template=cache\"");
 
                 return null;
             }
@@ -186,7 +219,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     public void testDropTable() throws Exception {
         executeDdl("CREATE TABLE IF NOT EXISTS \"Person\" (\"id\" int, \"city\" varchar,"
+
             " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
-            "\"cacheTemplate=cache\"");
+            "\"template=cache\"");
 
         executeDdl("DROP TABLE \"Person\"");
 
@@ -250,7 +283,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     public void testDestroyDynamicSqlCache() throws Exception {
         executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," +
             " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
-            "\"cacheTemplate=cache\"");
+            "\"template=cache\"");
 
         GridTestUtils.assertThrows(null, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -270,7 +303,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
     public void testSqlFlagCompatibilityCheck() throws Exception {
         executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar, \"name\" varchar,
\"surname\" varchar, " +
-            "\"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH \"cacheTemplate=cache\"");
+            "\"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH \"template=cache\"");
 
         GridTestUtils.assertThrows(null, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -282,6 +315,31 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
+     * Execute {@code CREATE TABLE} w/given params.
+     * @param params Engine parameters.
+     */
+    private void createTableWithParams(final String params) {
+        cache().query(new SqlFieldsQuery("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar"
+
+            ", \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\"))
WITH " +
+            "\"template=cache," + params + '"'));
+    }
+
+    /**
+     * Execute {@code CREATE TABLE} w/given params expecting a particular error.
+     * @param params Engine parameters.
+     * @param expErrMsg Expected error message.
+     */
+    private void assertCreateTableWithParamsThrows(final String params, String expErrMsg)
{
+        GridTestUtils.assertThrows(null, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                createTableWithParams(params);
+
+                return null;
+            }
+        }, IgniteSQLException.class, expErrMsg);
+    }
+
+    /**
      * Test that {@code CREATE TABLE} on non-public schema causes an exception.
      *
      * @throws Exception if failed.
@@ -292,7 +350,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
             @Override public Object call() throws Exception {
                 executeDdl("CREATE TABLE \"cache_idx\".\"Person\" (\"id\" int, \"city\" varchar,"
+
                     " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\",
\"city\")) WITH " +
-                    "\"cacheTemplate=cache\"");
+                    "\"template=cache\"");
 
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb27815/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index b66a343..8f9db2e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -579,7 +579,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
                 c("surname", Value.STRING), c("age", Value.INT)),
             "CREATE TABLE IF NOT EXISTS sch1.\"Person\" (\"id\" integer, \"city\" varchar,"
+
                 " \"name\" varchar, \"surname\" varchar, \"age\" integer, PRIMARY KEY (\"id\",
\"city\")) WITH " +
-                "\"cacheTemplate=cache\"");
+                "\"template=cache\"");
 
         assertCreateTableEquals(
             buildCreateTable("sch1", "Person", "cache", F.asList("id"),
@@ -587,7 +587,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
                 c("surname", Value.STRING), c("age", Value.INT)),
             "CREATE TABLE sch1.\"Person\" (\"id\" integer PRIMARY KEY, \"city\" varchar,"
+
                 " \"name\" varchar, \"surname\" varchar, \"age\" integer) WITH " +
-                "\"cacheTemplate=cache\"");
+                "\"template=cache\"");
 
         assertParseThrows("create table Person (id int)",
             IgniteSQLException.class, "No PRIMARY KEY defined for CREATE TABLE");
@@ -599,27 +599,27 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
             IgniteSQLException.class, "No cache value related columns found");
 
         assertParseThrows("create table Person (id int primary key, age int null)",
-            IgniteSQLException.class, "Mandatory param is missing [paramName=cacheTemplate]");
+            IgniteSQLException.class, "Mandatory parameter is missing: TEMPLATE");
 
-        assertParseThrows("create table Person (id int primary key, age int not null) WITH
\"cacheTemplate=cache\"",
+        assertParseThrows("create table Person (id int primary key, age int not null) WITH
\"template=cache\"",
             IgniteSQLException.class, "Non nullable columns are forbidden");
 
-        assertParseThrows("create table Person (id int primary key, age int unique) WITH
\"cacheTemplate=cache\"",
+        assertParseThrows("create table Person (id int primary key, age int unique) WITH
\"template=cache\"",
             IgniteSQLException.class, "Too many constraints - only PRIMARY KEY is supported
for CREATE TABLE");
 
-        assertParseThrows("create table Person (id int auto_increment primary key, age int)
WITH \"cacheTemplate=cache\"",
+        assertParseThrows("create table Person (id int auto_increment primary key, age int)
WITH \"template=cache\"",
             IgniteSQLException.class, "AUTO_INCREMENT columns are not supported");
 
-        assertParseThrows("create table Person (id int primary key check id > 0, age int)
WITH \"cacheTemplate=cache\"",
+        assertParseThrows("create table Person (id int primary key check id > 0, age int)
WITH \"template=cache\"",
             IgniteSQLException.class, "Column CHECK constraints are not supported [colName=ID]");
 
-        assertParseThrows("create table Person (id int as age * 2 primary key, age int) WITH
\"cacheTemplate=cache\"",
+        assertParseThrows("create table Person (id int as age * 2 primary key, age int) WITH
\"template=cache\"",
             IgniteSQLException.class, "Computed columns are not supported [colName=ID]");
 
-        assertParseThrows("create table Person (id int primary key, age int default 5) WITH
\"cacheTemplate=cache\"",
+        assertParseThrows("create table Person (id int primary key, age int default 5) WITH
\"template=cache\"",
             IgniteSQLException.class, "DEFAULT expressions are not supported [colName=AGE]");
 
-        assertParseThrows("create table Int (_key int primary key, _val int) WITH \"cacheTemplate=cache\"",
+        assertParseThrows("create table Int (_key int primary key, _val int) WITH \"template=cache\"",
             IgniteSQLException.class, "Direct specification of _KEY and _VAL columns is forbidden");
     }
 
@@ -706,7 +706,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
     private static void assertCreateTableEquals(GridSqlCreateTable exp, GridSqlCreateTable
actual) {
         assertEqualsIgnoreCase(exp.schemaName(), actual.schemaName());
         assertEqualsIgnoreCase(exp.tableName(), actual.tableName());
-        assertEquals(exp.templateCacheName(), actual.templateCacheName());
+        assertEquals(exp.templateName(), actual.templateName());
         assertEquals(exp.primaryKeyColumns(), actual.primaryKeyColumns());
         assertEquals(new ArrayList<>(exp.columns().keySet()), new ArrayList<>(actual.columns().keySet()));
 
@@ -733,7 +733,7 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
 
         res.tableName(tbl);
 
-        res.templateCacheName(tplCacheName);
+        res.templateName(tplCacheName);
 
         res.primaryKeyColumns(new LinkedHashSet<>(pkColNames));
 


Mime
View raw message