This is an automated email from the ASF dual-hosted git repository.
jooger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new d09ea51466 IGNITE-23353 Improve CREATE TABLE syntax (#4599)
d09ea51466 is described below
commit d09ea5146669f885955129a24221b6371f232a94
Author: ygerzhedovich <[email protected]>
AuthorDate: Mon Nov 4 10:17:02 2024 +0200
IGNITE-23353 Improve CREATE TABLE syntax (#4599)
---
docs/_docs/developers-guide/java-to-tables.adoc | 2 +-
docs/_docs/sql-reference/ddl.adoc | 43 +++-----
docs/_docs/sql-reference/grammar-reference.adoc | 6 +-
.../example/storage/StorageEngineExample.java | 2 +-
.../org/apache/ignite/catalog/IgniteCatalog.java | 2 +-
.../catalog/definitions/TableDefinition.java | 2 +-
.../internal/catalog/sql/CreateTableImpl.java | 11 +-
.../apache/ignite/internal/catalog/sql/Option.java | 4 -
.../apache/ignite/internal/catalog/sql/Zone.java} | 21 ++--
.../catalog/sql/CreateFromAnnotationsTest.java | 6 +-
.../catalog/sql/CreateFromDefinitionTest.java | 6 +-
.../internal/catalog/sql/CreateTableTest.java | 2 +-
.../ignite/internal/catalog/sql/QueryPartTest.java | 12 ---
.../internal/catalog/it/ItConcurrentDdlsTest.java | 2 +-
.../partitions/reset/ItResetPartitionsTest.java | 2 +-
.../restart/ItRestartPartitionsTest.java | 2 +-
.../partitions/states/ItPartitionStatesTest.java | 2 +-
.../cli/commands/sql/ItSqlCommandTest.java | 12 ---
.../cli/commands/sql/help/IgniteSqlCommand.java | 4 +-
.../internal/compute/ItWorkerShutdownTest.java | 2 +-
.../ItDistributionZonesFiltersTest.java | 4 +-
.../internal/index/ItBuildIndexOneNodeTest.java | 2 +-
.../ignite/internal/index/ItBuildIndexTest.java | 2 +-
.../ItPrimaryReplicaChoiceTest.java | 2 +-
...asterRecoveryControllerResetPartitionsTest.java | 3 +-
...terRecoveryControllerRestartPartitionsTest.java | 2 +-
.../recovery/ItDisasterRecoveryControllerTest.java | 2 +-
.../benchmark/AbstractMultiNodeBenchmark.java | 2 +-
.../internal/benchmark/SqlIndexScanBenchmark.java | 2 +-
.../inmemory/ItRaftStorageVolatilityTest.java | 16 +--
.../app/ItIgniteInMemoryNodeRestartTest.java | 2 +-
.../runner/app/ItIgniteNodeRestartTest.java | 9 +-
.../runner/app/ItReplicaStateManagerTest.java | 2 +-
.../app/client/ItAbstractThinClientTest.java | 2 +-
.../schemasync/ItSchemaSyncAndReplicationTest.java | 2 +-
.../schemasync/ItSchemaSyncMultiNodeTest.java | 2 +-
.../ignite/internal/table/ItDurableFinishTest.java | 2 +-
.../ignite/internal/table/ItInternalTableTest.java | 6 +-
.../internal/table/ItReadOnlyTransactionTest.java | 2 +-
.../ignite/internal/table/ItTableScanTest.java | 26 +++--
.../partition/ItAbstractPartitionManagerTest.java | 2 +-
.../internal/ClusterPerClassIntegrationTest.java | 2 +-
.../internal/sql/engine/ItAggregatesTest.java | 2 +-
.../internal/sql/engine/ItCreateTableDdlTest.java | 23 ++--
.../internal/sql/engine/ItIndexSpoolTest.java | 4 +-
.../sql/engine/ItPkOnlyTableCrossApiTest.java | 2 +-
.../integrationTest/sql/set/test_basic_union.test | 2 -
modules/sql-engine/src/main/codegen/config.fmpp | 5 +-
.../src/main/codegen/includes/parserImpls.ftl | 44 ++------
.../prepare/ddl/DdlSqlToCommandConverter.java | 44 +++-----
.../sql/engine/sql/IgniteSqlCreateTable.java | 37 ++++---
.../sql/engine/sql/IgniteSqlCreateTableOption.java | 120 ---------------------
.../prepare/ddl/DdlSqlToCommandConverterTest.java | 96 ++++++++---------
.../sql/engine/sql/CommentParsingTest.java | 2 +-
.../internal/sql/engine/sql/SqlDdlParserTest.java | 76 ++-----------
.../distributed/ItPartitionStoragesTest.java | 2 +-
.../disaster/ItDisasterRecoveryManagerTest.java | 2 +-
.../ItDisasterRecoveryReconfigurationTest.java | 2 +-
.../raftsnapshot/ItTableRaftSnapshotsTest.java | 2 +-
.../rebalance/ItRebalanceRecoveryTest.java | 2 +-
.../ignite/internal/rebalance/ItRebalanceTest.java | 2 +-
.../rebalance/ItRebalanceTriggersRecoveryTest.java | 6 +-
.../ignite/internal/table/ItEstimatedSizeTest.java | 2 +-
.../internal/table/ItOperationRetryTest.java | 2 +-
.../table/ItTransactionPrimaryChangeTest.java | 2 +-
.../internal/table/ItTransactionRecoveryTest.java | 17 +--
.../internal/table/ItTxResourcesVacuumTest.java | 4 +-
67 files changed, 242 insertions(+), 501 deletions(-)
diff --git a/docs/_docs/developers-guide/java-to-tables.adoc
b/docs/_docs/developers-guide/java-to-tables.adoc
index 7e1c0f22fe..b2f9a6fef0 100644
--- a/docs/_docs/developers-guide/java-to-tables.adoc
+++ b/docs/_docs/developers-guide/java-to-tables.adoc
@@ -93,7 +93,7 @@ CREATE TABLE IF NOT EXISTS kv_pojo_test (
PRIMARY KEY (id, id_str desc)
)
COLOCATE BY (f_name, l_name)
-WITH PRIMARY_ZONE='ZONE_TEST';
+ZONE ZONE_TEST;
CREATE INDEX ix_test (f_name, l_name desc nulls last);
----
diff --git a/docs/_docs/sql-reference/ddl.adoc
b/docs/_docs/sql-reference/ddl.adoc
index 3fc67907da..47768be7fe 100644
--- a/docs/_docs/sql-reference/ddl.adoc
+++ b/docs/_docs/sql-reference/ddl.adoc
@@ -49,15 +49,14 @@ NonTerminal('column_list',
{href:'./grammar-reference/#column_list'})
),
Optional(
Sequence(
-Terminal('WITH'),
-OneOrMore (NonTerminal('parameter', {href:'./grammar-reference/#parameter'}),
Terminal(','))
+Terminal('ZONE'),
+NonTerminal('zone_name')
)
),
Optional(
Sequence(
-Terminal('EXPIRE'),
-Terminal('AT'),
-NonTerminal('expiry_column_name')
+Terminal('STORAGE ENGINE'),
+NonTerminal('storage_engine_name')
)
)
)
@@ -67,10 +66,8 @@ Keywords and parameters:
* `table_name` - name of the table. Can be schema-qualified.
* `IF NOT EXISTS` - create the table only if a table with the same name does
not exist.
* `COLOCATE BY` - colocation key. The key can be composite. Primary key must
include colocation key. Was `affinity_key` in Ignite 2.x.
-* `WITH` - accepts additional parameters; currently, accepts only:
-** `PRIMARY_ZONE` - sets the
link:sql-reference/distribution-zones[Distribution Zone].
-* `EXPIRE AT` - allows specifying a column with a point in time when a record
should be deleted.
-* `expiry_column_name` - name of the column that contains values on which the
record expiry is based.
+* `ZONE` - sets the link:sql-reference/distribution-zones[Distribution Zone].
+* `STORAGE ENGINE` - sets the
link:sql-reference/distribution-zones[Distribution Zone].
Examples:
@@ -97,18 +94,7 @@ CREATE TABLE IF NOT EXISTS Person (
name varchar,
age int,
company varchar
-) WITH PRIMARY_ZONE=`MYZONE`
-----
-
-Creates a Person table where the records expire at timestamps in the `ttl`
column:
-
-[source,sql]
-----
-CREATE TABLE IF NOT EXISTS Person (
- id int PRIMARY KEY,
- name varchar,
- ttl timestamp
-) EXPIRE AT ttl
+) ZONE MYZONE
----
Creates a Person table where the default value if the `city_id` column is 1:
@@ -612,15 +598,14 @@ NonTerminal('column_list',
{href:'./grammar-reference/#column_list'})
),
Optional(
Sequence(
-Terminal('WITH'),
-OneOrMore (NonTerminal('parameter', {href:'./grammar-reference/#parameter'}),
Terminal(','))
+Terminal('ZONE'),
+NonTerminal('zone_name')
)
),
Optional(
Sequence(
-Terminal('EXPIRE'),
-Terminal('AT'),
-NonTerminal('expiry_column_name')
+Terminal('STORAGE ENGINE'),
+NonTerminal('storage_engine_name')
)
)
)
@@ -630,7 +615,5 @@ Keywords and parameters:
* `cache_name` - name of the cache. Can be schema-qualified.
* `IF NOT EXISTS` - create the cache only if a cache with the same name does
not exist.
* `COLOCATE BY` - colocation key. The key can be composite. Primary key must
include colocation key. Was `affinity_key` in Ignite 2.x.
-* `WITH` - accepts additional parameters; currently, accepts only:
-** `PRIMARY_ZONE` - sets the
link:sql-reference/distribution-zones[Distribution Zone]. The selected
distribution zone must use `aimem` storage engine.
-* `EXPIRE AT` - allows specifying a column with a point in time when a record
should be deleted.
-* `expiry_column_name` - name of the column that contains values on which the
record expiry is based.
+* `ZONE` - sets the link:sql-reference/distribution-zones[Distribution Zone].
The selected distribution zone must use `aimem` storage engine.
+* `STORAGE ENGINE` - sets the
link:sql-reference/distribution-zones[Distribution Zone].
\ No newline at end of file
diff --git a/docs/_docs/sql-reference/grammar-reference.adoc
b/docs/_docs/sql-reference/grammar-reference.adoc
index 8cf7efe452..f54faef4c5 100644
--- a/docs/_docs/sql-reference/grammar-reference.adoc
+++ b/docs/_docs/sql-reference/grammar-reference.adoc
@@ -197,21 +197,21 @@ When a parameter is specified, you can provide it as a
literal value or as an id
----
CREATE ZONE test_zone WITH STORAGE_PROFILES='default';
-CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE=test_zone;
+CREATE TABLE test_table (id INT PRIMARY KEY, val INT) ZONE test_zone;
----
In this case, `test_zone` is the identifier, and is used as an identifier.
When used like this, the parameters are not case-sensitive.
----
CREATE ZONE "test_zone" WITH STORAGE_PROFILES='default';
-CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE='test_zone';
+CREATE TABLE test_table (id INT PRIMARY KEY, val INT) ZONE "test_zone";
----
In this case, `test_zone` is created as a literal value, and is used as a
literal. When used like this, the parameter is case-sensitive.
----
CREATE ZONE test_zone WITH STORAGE_PROFILES='default';
-CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE=`TEST_ZONE`;
+CREATE TABLE test_table (id INT PRIMARY KEY, val INT) ZONE TEST_ZONE;
----
In this case, `test_zone` is created as an identifier, and is
case-insensitive. As such, when `TEST_ZONE` is used as a literal, it still
matches the identifier.
diff --git
a/examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
b/examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
index 16f58a0f4a..c0a90856a0 100644
---
a/examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
+++
b/examples/src/main/java/org/apache/ignite/example/storage/StorageEngineExample.java
@@ -71,7 +71,7 @@ class StorageEngineExample {
+ "FIRST_NAME VARCHAR, "
+ "LAST_NAME VARCHAR, "
+ "BALANCE DOUBLE) "
- + "WITH PRIMARY_ZONE = 'ACCOUNTS_ZONE'"
+ + "ZONE ACCOUNTS_ZONE"
);
}
diff --git
a/modules/api/src/main/java/org/apache/ignite/catalog/IgniteCatalog.java
b/modules/api/src/main/java/org/apache/ignite/catalog/IgniteCatalog.java
index fc46666280..3fa4488f31 100644
--- a/modules/api/src/main/java/org/apache/ignite/catalog/IgniteCatalog.java
+++ b/modules/api/src/main/java/org/apache/ignite/catalog/IgniteCatalog.java
@@ -109,7 +109,7 @@ import org.apache.ignite.table.Table;
* <pre>
* CREATE ZONE IF NOT EXISTS zone_test WITH PARTITIONS=1, REPLICAS=3,
STORAGE_PROFILES='default';
* CREATE TABLE IF NOT EXISTS table_test (id int, id_str varchar(20),
f_name varchar(20) not null default 'a', \
- * l_name varchar, str varchar, PRIMARY KEY (id, id_str)) COLOCATE BY (id,
id_str) WITH PRIMARY_ZONE='ZONE_TEST';
+ * l_name varchar, str varchar, PRIMARY KEY (id, id_str)) COLOCATE BY (id,
id_str) ZONE ZONE_TEST;
* CREATE INDEX IF NOT EXISTS ix_pojo ON table_test (f_name, l_name desc);
* </pre>
* And here's the equivalent definition using builders:
diff --git
a/modules/api/src/main/java/org/apache/ignite/catalog/definitions/TableDefinition.java
b/modules/api/src/main/java/org/apache/ignite/catalog/definitions/TableDefinition.java
index e6c0fabf50..2dc262a743 100644
---
a/modules/api/src/main/java/org/apache/ignite/catalog/definitions/TableDefinition.java
+++
b/modules/api/src/main/java/org/apache/ignite/catalog/definitions/TableDefinition.java
@@ -148,7 +148,7 @@ public class TableDefinition {
/**
* Returns primary zone name.
*
- * @return Zone name to use in the {@code WITH PRIMARY_ZONE} option or
{@code null} if not specified.
+ * @return Zone name to use in the {@code ZONE} option or {@code null} if
not specified.
*/
public @Nullable String zoneName() {
return zoneName;
diff --git
a/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateTableImpl.java
b/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateTableImpl.java
index d29159e8b6..c0a46ddbf5 100644
---
a/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateTableImpl.java
+++
b/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/CreateTableImpl.java
@@ -38,10 +38,10 @@ class CreateTableImpl extends AbstractCatalogQuery<Name> {
private final List<Constraint> constraints = new ArrayList<>();
- private final List<Option> withOptions = new ArrayList<>();
-
private Colocate colocate;
+ private Zone zone;
+
private final List<CreateIndexImpl> indexes = new ArrayList<>();
/**
@@ -119,7 +119,7 @@ class CreateTableImpl extends AbstractCatalogQuery<Name> {
CreateTableImpl zone(String zone) {
Objects.requireNonNull(zone, "Zone name must not be null.");
- withOptions.add(Option.primaryZone(zone));
+ this.zone = new Zone(zone.toUpperCase());
return this;
}
@@ -172,9 +172,8 @@ class CreateTableImpl extends AbstractCatalogQuery<Name> {
ctx.sql(" ").visit(colocate);
}
- if (!withOptions.isEmpty()) {
- ctx.sql(" ").sql("WITH ");
- ctx.visit(partsList(withOptions));
+ if (zone != null) {
+ ctx.sql(" ").visit(zone);
}
ctx.sql(";");
diff --git
a/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Option.java
b/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Option.java
index 56bdb665f5..5f1b8ae955 100644
---
a/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Option.java
+++
b/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Option.java
@@ -27,10 +27,6 @@ class Option extends QueryPart {
this.value = value;
}
- public static Option primaryZone(String zone) {
- return new Option("PRIMARY_ZONE", zone.toUpperCase());
- }
-
public static Option partitions(Integer partitions) {
return new Option("PARTITIONS", partitions);
}
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/TableOptionEnum.java
b/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Zone.java
similarity index 75%
rename from
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/TableOptionEnum.java
rename to
modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Zone.java
index 4f477141f1..54ca13f54f 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/TableOptionEnum.java
+++
b/modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/Zone.java
@@ -15,15 +15,18 @@
* limitations under the License.
*/
-package org.apache.ignite.internal.sql.engine.prepare.ddl;
+package org.apache.ignite.internal.catalog.sql;
-/**
- * Enumerates the options for CREATE TABLE and ALTER TABLE statements.
- */
-public enum TableOptionEnum {
- /** Primary zone. */
- PRIMARY_ZONE,
+class Zone extends QueryPart {
+
+ private final String zone;
+
+ Zone(String zone) {
+ this.zone = zone;
+ }
- /** Storage profile. */
- STORAGE_PROFILE
+ @Override
+ protected void accept(QueryContext ctx) {
+ ctx.sql("ZONE " + zone);
+ }
}
diff --git
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromAnnotationsTest.java
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromAnnotationsTest.java
index 367bcb2e58..e72376cf8e 100644
---
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromAnnotationsTest.java
+++
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromAnnotationsTest.java
@@ -107,7 +107,7 @@ class CreateFromAnnotationsTest {
+ " DATA_NODES_FILTER='filter';"
+ System.lineSeparator()
+ "CREATE TABLE IF NOT EXISTS PUBLIC.pojo_value_test
(id int, f_name varchar, l_name varchar, str varchar,"
- + " PRIMARY KEY (id)) COLOCATE BY (id, id_str) WITH
PRIMARY_ZONE='ZONE_TEST';"
+ + " PRIMARY KEY (id)) COLOCATE BY (id, id_str) ZONE
ZONE_TEST;"
+ System.lineSeparator()
+ "CREATE INDEX IF NOT EXISTS ix_pojo ON
PUBLIC.pojo_value_test (f_name, l_name desc);")
);
@@ -125,7 +125,7 @@ class CreateFromAnnotationsTest {
+ " DATA_NODES_FILTER='filter';"
+ System.lineSeparator()
+ "CREATE TABLE IF NOT EXISTS PUBLIC.pojo_value_test
(id int, id_str varchar(20), f_name varchar, l_name varchar,"
- + " str varchar, PRIMARY KEY (id, id_str)) COLOCATE BY
(id, id_str) WITH PRIMARY_ZONE='ZONE_TEST';"
+ + " str varchar, PRIMARY KEY (id, id_str)) COLOCATE BY
(id, id_str) ZONE ZONE_TEST;"
+ System.lineSeparator()
+ "CREATE INDEX IF NOT EXISTS ix_pojo ON
PUBLIC.pojo_value_test (f_name, l_name desc);")
);
@@ -144,7 +144,7 @@ class CreateFromAnnotationsTest {
+ "CREATE TABLE IF NOT EXISTS PUBLIC.pojo_test"
+ " (id int, id_str varchar(20), f_name varchar(20)
not null default 'a',"
+ " l_name varchar, str varchar, PRIMARY KEY (id,
id_str))"
- + " COLOCATE BY (id, id_str) WITH
PRIMARY_ZONE='ZONE_TEST';"
+ + " COLOCATE BY (id, id_str) ZONE ZONE_TEST;"
+ System.lineSeparator()
+ "CREATE INDEX IF NOT EXISTS ix_pojo ON
PUBLIC.pojo_test (f_name, l_name desc);")
);
diff --git
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionTest.java
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionTest.java
index 721fe47c9e..4643619f89 100644
---
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionTest.java
+++
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateFromDefinitionTest.java
@@ -103,7 +103,7 @@ class CreateFromDefinitionTest {
createTable(table),
is("CREATE TABLE IF NOT EXISTS PUBLIC.builder_test"
+ " (id int, id_str varchar, f_name varchar(20) NOT
NULL DEFAULT 'a', PRIMARY KEY (id, id_str))"
- + " COLOCATE BY (id, id_str) WITH
PRIMARY_ZONE='ZONE_TEST';"
+ + " COLOCATE BY (id, id_str) ZONE ZONE_TEST;"
+ System.lineSeparator()
+ "CREATE INDEX IF NOT EXISTS ix_id_str_f_name ON
PUBLIC.builder_test (id_str, f_name);"
+ System.lineSeparator()
@@ -153,7 +153,7 @@ class CreateFromDefinitionTest {
createTable(tableDefinition),
is("CREATE TABLE PUBLIC.pojo_value_test"
+ " (id int, id_str varchar(20), f_name varchar,
l_name varchar, str varchar, PRIMARY KEY (id, id_str))"
- + " COLOCATE BY (id, id_str) WITH
PRIMARY_ZONE='ZONE_TEST';")
+ + " COLOCATE BY (id, id_str) ZONE ZONE_TEST;")
);
}
@@ -170,7 +170,7 @@ class CreateFromDefinitionTest {
createTable(tableDefinition),
is("CREATE TABLE IF NOT EXISTS PUBLIC.pojo_test (id int,
id_str varchar(20),"
+ " f_name varchar(20) not null default 'a', l_name
varchar, str varchar,"
- + " PRIMARY KEY (id, id_str)) COLOCATE BY (id, id_str)
WITH PRIMARY_ZONE='ZONE_TEST';")
+ + " PRIMARY KEY (id, id_str)) COLOCATE BY (id, id_str)
ZONE ZONE_TEST;")
);
}
diff --git
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateTableTest.java
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateTableTest.java
index 9815f3a6d2..2ed0ca9f6b 100644
---
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateTableTest.java
+++
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/CreateTableTest.java
@@ -115,7 +115,7 @@ class CreateTableTest {
Query query1 = createTable().name("table1").addColumn("col1", INTEGER)
.zone("zone1");
String sql = query1.toString(); // zone param is lowercase
- assertThat(sql, is("CREATE TABLE table1 (col1 int) WITH
PRIMARY_ZONE='ZONE1';")); // zone result is uppercase
+ assertThat(sql, is("CREATE TABLE table1 (col1 int) ZONE ZONE1;")); //
zone result is uppercase
}
@Test
diff --git
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/QueryPartTest.java
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/QueryPartTest.java
index 5b0f906108..a3b72dcbc3 100644
---
a/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/QueryPartTest.java
+++
b/modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/QueryPartTest.java
@@ -136,18 +136,6 @@ class QueryPartTest {
assertThat(sql(constraint), is("PRIMARY KEY USING SORTED (a, b)"));
}
- @Test
- void withOptionPart() {
- Option withOption = Option.primaryZone("z");
- assertThat(sql(withOption), is("PRIMARY_ZONE='Z'"));
-
- withOption = Option.partitions(1);
- assertThat(sql(withOption), is("PARTITIONS=1"));
-
- withOption = Option.replicas(1);
- assertThat(sql(withOption), is("REPLICAS=1"));
- }
-
@Test
void queryPartCollection() {
QueryPartCollection<Name> collection =
QueryPartCollection.partsList(new Name("a"), new Name("b"));
diff --git
a/modules/catalog/src/integrationTest/java/org/apache/ignite/internal/catalog/it/ItConcurrentDdlsTest.java
b/modules/catalog/src/integrationTest/java/org/apache/ignite/internal/catalog/it/ItConcurrentDdlsTest.java
index 4a570ed12e..56f79a2428 100644
---
a/modules/catalog/src/integrationTest/java/org/apache/ignite/internal/catalog/it/ItConcurrentDdlsTest.java
+++
b/modules/catalog/src/integrationTest/java/org/apache/ignite/internal/catalog/it/ItConcurrentDdlsTest.java
@@ -62,7 +62,7 @@ class ItConcurrentDdlsTest extends
ClusterPerTestIntegrationTest {
String tableName = "TEST" + n;
node(0).sql().executeScript(
- "CREATE TABLE " + tableName + " (id INT PRIMARY KEY, val
VARCHAR) WITH primary_zone='" + ZONE_NAME + "'"
+ "CREATE TABLE " + tableName + " (id INT PRIMARY KEY, val
VARCHAR) ZONE " + ZONE_NAME
);
});
}
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java
index 1d6e8b8651..e7ab2f6bef 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/reset/ItResetPartitionsTest.java
@@ -40,7 +40,7 @@ public abstract class ItResetPartitionsTest extends
CliIntegrationTest {
@BeforeAll
public void createTables() {
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
- sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) WITH PRIMARY_ZONE = '%s'", TABLE_NAME, ZONE));
+ sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) ZONE \"%s\"", TABLE_NAME, ZONE));
}
@Test
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java
index a557bb024c..c27464374f 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/restart/ItRestartPartitionsTest.java
@@ -43,7 +43,7 @@ public abstract class ItRestartPartitionsTest extends
CliIntegrationTest {
@BeforeAll
public void createTables() {
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
- sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) WITH PRIMARY_ZONE = '%s'", TABLE_NAME, ZONE));
+ sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) ZONE \"%s\"", TABLE_NAME, ZONE));
}
@Test
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/states/ItPartitionStatesTest.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/states/ItPartitionStatesTest.java
index bd5e91a3a6..d963899abc 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/states/ItPartitionStatesTest.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/partitions/states/ItPartitionStatesTest.java
@@ -61,7 +61,7 @@ public abstract class ItPartitionStatesTest extends
CliIntegrationTest {
public static void createTables() {
ZONES_CONTAINING_TABLES.forEach(name -> {
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
name, DEFAULT_AIPERSIST_PROFILE_NAME));
- sql(String.format("CREATE TABLE \"%s_table\" (id INT PRIMARY KEY,
val INT) WITH PRIMARY_ZONE = '%1$s'", name));
+ sql(String.format("CREATE TABLE \"%s_table\" (id INT PRIMARY KEY,
val INT) ZONE \"%1$s\"", name));
});
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
EMPTY_ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
diff --git
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/sql/ItSqlCommandTest.java
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/sql/ItSqlCommandTest.java
index 416319d22d..83b6d1cd92 100644
---
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/sql/ItSqlCommandTest.java
+++
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/sql/ItSqlCommandTest.java
@@ -76,18 +76,6 @@ class ItSqlCommandTest extends CliSqlCommandTestBase {
);
}
- @Test
- @DisplayName("Should display readable error when wrong option is given on
CREATE TABLE")
- void incorrectEngineOnCreate() {
- execute("sql", "create table mytable1(i int, j int, primary key (i))
with notexist='nusuch'", "--jdbc-url", JDBC_URL);
-
- assertAll(
- () -> assertExitCodeIs(1),
- this::assertOutputIsEmpty,
- () -> assertErrOutputContains("Unexpected table option
[option=NOTEXIST")
- );
- }
-
@Test
@DisplayName("Should display readable error when not SQL expression given")
void notSqlExpression() {
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/help/IgniteSqlCommand.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/help/IgniteSqlCommand.java
index c08a36e823..814833a1eb 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/help/IgniteSqlCommand.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/help/IgniteSqlCommand.java
@@ -50,8 +50,8 @@ public enum IgniteSqlCommand {
CREATE_TABLE("CREATE TABLE",
"CREATE TABLE [IF NOT EXISTS] tableName (tableColumn [,
tableColumn]...)\n"
+ "[COLOCATE [BY] (columnName [, columnName]...)]\n"
- + "[WITH paramName=paramValue
[,paramName=paramValue]...]\n"
- + "[EXPIRE AT columnName]\n"
+ + "[ZONE zoneName]\n"
+ + "[STORAGE PROFILE storageProfile]\n"
+ "tableColumn = columnName columnType [[NOT] NULL]
[DEFAULT defaultValue] [PRIMARY KEY]"),
create_table("create table", CREATE_TABLE.syntax),
diff --git
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItWorkerShutdownTest.java
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItWorkerShutdownTest.java
index d088b89f69..59c4191974 100644
---
a/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItWorkerShutdownTest.java
+++
b/modules/compute/src/integrationTest/java/org/apache/ignite/internal/compute/ItWorkerShutdownTest.java
@@ -380,7 +380,7 @@ public abstract class ItWorkerShutdownTest extends
ClusterPerTestIntegrationTest
// Number of replicas == number of nodes and number of partitions ==
1. This gives us the majority on primary replica stop.
// After the primary replica is stopped we still be able to select new
primary replica selected.
executeSql("CREATE ZONE TEST_ZONE WITH REPLICAS=3, PARTITIONS=1,
STORAGE_PROFILES='" + DEFAULT_STORAGE_PROFILE + "'");
- executeSql("CREATE TABLE test (k int, v int, CONSTRAINT PK PRIMARY KEY
(k)) WITH PRIMARY_ZONE='TEST_ZONE'");
+ executeSql("CREATE TABLE test (k int, v int, CONSTRAINT PK PRIMARY KEY
(k)) ZONE TEST_ZONE");
executeSql("INSERT INTO test(k, v) VALUES (1, 101)");
}
diff --git
a/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/distributionzones/ItDistributionZonesFiltersTest.java
b/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/distributionzones/ItDistributionZonesFiltersTest.java
index 6db9a426b9..677988906a 100644
---
a/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/distributionzones/ItDistributionZonesFiltersTest.java
+++
b/modules/distribution-zones/src/integrationTest/java/org/apache/ignite/internal/distributionzones/ItDistributionZonesFiltersTest.java
@@ -465,8 +465,8 @@ public class ItDistributionZonesFiltersTest extends
ClusterPerTestIntegrationTes
private static String createTableSql() {
return String.format(
- "CREATE TABLE %s(%s INT PRIMARY KEY, %s VARCHAR) WITH
STORAGE_PROFILE='%s',PRIMARY_ZONE='%s'",
- TABLE_NAME, COLUMN_KEY, COLUMN_VAL,
DEFAULT_AIPERSIST_PROFILE_NAME, ZONE_NAME
+ "CREATE TABLE %s(%s INT PRIMARY KEY, %s VARCHAR) ZONE %s
STORAGE PROFILE '%s'",
+ TABLE_NAME, COLUMN_KEY, COLUMN_VAL, ZONE_NAME,
DEFAULT_AIPERSIST_PROFILE_NAME
);
}
diff --git
a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
index 99ed983898..eeb5333ba1 100644
---
a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
+++
b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexOneNodeTest.java
@@ -379,7 +379,7 @@ public class ItBuildIndexOneNodeTest extends
BaseSqlIntegrationTest {
// Use hash index for primary key, otherwise if sorted index exists,
// the optimizer might choose it (the primary key index) instead of an
existing sorted one.
sql(format(
- "CREATE TABLE IF NOT EXISTS {} (id INT, name VARCHAR, salary
DOUBLE, PRIMARY KEY USING HASH (id)) WITH PRIMARY_ZONE='{}'",
+ "CREATE TABLE IF NOT EXISTS {} (id INT, name VARCHAR, salary
DOUBLE, PRIMARY KEY USING HASH (id)) ZONE {}",
TABLE_NAME, ZONE_NAME
));
diff --git
a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java
b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java
index 5fd73bb40b..ee9525822a 100644
---
a/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java
+++
b/modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java
@@ -206,7 +206,7 @@ public class ItBuildIndexTest extends
BaseSqlIntegrationTest {
));
sql(format(
- "CREATE TABLE {} (i0 INTEGER PRIMARY KEY, i1 INTEGER) WITH
PRIMARY_ZONE='{}'",
+ "CREATE TABLE {} (i0 INTEGER PRIMARY KEY, i1 INTEGER) ZONE {}",
TABLE_NAME, ZONE_NAME
));
diff --git
a/modules/placement-driver/src/integrationTest/java/org/apache/ignite/internal/placementdriver/ItPrimaryReplicaChoiceTest.java
b/modules/placement-driver/src/integrationTest/java/org/apache/ignite/internal/placementdriver/ItPrimaryReplicaChoiceTest.java
index e9f3c60537..1756d0562d 100644
---
a/modules/placement-driver/src/integrationTest/java/org/apache/ignite/internal/placementdriver/ItPrimaryReplicaChoiceTest.java
+++
b/modules/placement-driver/src/integrationTest/java/org/apache/ignite/internal/placementdriver/ItPrimaryReplicaChoiceTest.java
@@ -101,7 +101,7 @@ public class ItPrimaryReplicaChoiceTest extends
ClusterPerTestIntegrationTest {
);
String sql = IgniteStringFormatter.format(
- "CREATE TABLE {} (key INT PRIMARY KEY, val VARCHAR(20)) WITH
PRIMARY_ZONE='{}'",
+ "CREATE TABLE {} (key INT PRIMARY KEY, val VARCHAR(20)) ZONE
{}",
TABLE_NAME, ZONE_NAME
);
diff --git
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerResetPartitionsTest.java
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerResetPartitionsTest.java
index ff12683cde..7d57b2dc57 100644
---
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerResetPartitionsTest.java
+++
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerResetPartitionsTest.java
@@ -55,8 +55,7 @@ public class ItDisasterRecoveryControllerResetPartitionsTest
extends ClusterPerC
@BeforeAll
public void setUp() {
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
FIRST_ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
- sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) WITH PRIMARY_ZONE = '%s'", TABLE_NAME,
- FIRST_ZONE));
+ sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) ZONE \"%s\"", TABLE_NAME, FIRST_ZONE));
}
@Test
diff --git
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java
index 2c4200b3b5..593c0b4ee3 100644
---
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java
+++
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerRestartPartitionsTest.java
@@ -65,7 +65,7 @@ public class
ItDisasterRecoveryControllerRestartPartitionsTest extends ClusterPe
@BeforeAll
public void setUp() {
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
FIRST_ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
- sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) WITH PRIMARY_ZONE = '%s'", TABLE_NAME,
+ sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val
INT) ZONE \"%s\"", TABLE_NAME,
FIRST_ZONE));
}
diff --git
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java
index 0ea5ed2437..c9136fbd5a 100644
---
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java
+++
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/recovery/ItDisasterRecoveryControllerTest.java
@@ -92,7 +92,7 @@ public class ItDisasterRecoveryControllerTest extends
ClusterPerClassIntegration
public static void setUp() {
ZONES_CONTAINING_TABLES.forEach(name -> {
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
name, DEFAULT_AIPERSIST_PROFILE_NAME));
- sql(String.format("CREATE TABLE PUBLIC.\"%s_table\" (id INT
PRIMARY KEY, val INT) WITH PRIMARY_ZONE = '%1$s'", name));
+ sql(String.format("CREATE TABLE PUBLIC.\"%s_table\" (id INT
PRIMARY KEY, val INT) ZONE \"%1$s\"", name));
});
sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'",
EMPTY_ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/AbstractMultiNodeBenchmark.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/AbstractMultiNodeBenchmark.java
index e6cc47d0ac..16117bf584 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/AbstractMultiNodeBenchmark.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/AbstractMultiNodeBenchmark.java
@@ -132,7 +132,7 @@ public class AbstractMultiNodeBenchmark {
createTableStatement += "\nCOLOCATE BY (" + String.join(", ",
colocationKeys) + ")";
}
- createTableStatement += "\nWITH primary_zone='" + ZONE_NAME + "'";
+ createTableStatement += "\nZONE " + ZONE_NAME;
getAllFromCursor(
await(igniteImpl.queryEngine().queryAsync(
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/SqlIndexScanBenchmark.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/SqlIndexScanBenchmark.java
index f39d79734c..abb51afeae 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/SqlIndexScanBenchmark.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/benchmark/SqlIndexScanBenchmark.java
@@ -92,7 +92,7 @@ public class SqlIndexScanBenchmark extends
AbstractMultiNodeBenchmark {
if
(!Files.exists(workDir().resolve(DATASET_READY_MARK_FILE_NAME))) {
sql.executeScript(
"CREATE ZONE single_partition_zone WITH replicas = 1,
partitions = 1;"
- + "CREATE TABLE test (id INT PRIMARY KEY, val
DATE) WITH primary_zone = single_partition_zone;"
+ + "CREATE TABLE test (id INT PRIMARY KEY, val
DATE) ZONE single_partition_zone;"
+ "CREATE INDEX test_val_idx ON test(val);"
);
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java
index 862795ea22..d6857e318e 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/inmemory/ItRaftStorageVolatilityTest.java
@@ -57,8 +57,8 @@ import org.rocksdb.RocksIterator;
import org.rocksdb.Slice;
/**
- * Tests for making sure that RAFT groups corresponding to partition stores of
in-memory tables use volatile
- * storages for storing RAFT meta and RAFT log, while they are persistent for
persistent storages.
+ * Tests for making sure that RAFT groups corresponding to partition stores of
in-memory tables use volatile storages for storing RAFT meta
+ * and RAFT log, while they are persistent for persistent storages.
*/
@WithSystemProperty(key =
SharedLogStorageFactoryUtils.LOGIT_STORAGE_ENABLED_PROPERTY, value = "false")
class ItRaftStorageVolatilityTest extends ClusterPerTestIntegrationTest {
@@ -82,8 +82,8 @@ class ItRaftStorageVolatilityTest extends
ClusterPerTestIntegrationTest {
executeSql("CREATE ZONE ZONE_" + TABLE_NAME + " WITH STORAGE_PROFILES
= '" + DEFAULT_AIMEM_PROFILE_NAME + "'");
executeSql("CREATE TABLE " + TABLE_NAME
- + " (k int, v int, CONSTRAINT PK PRIMARY KEY (k)) WITH
STORAGE_PROFILE='"
- + DEFAULT_AIMEM_PROFILE_NAME + "', PRIMARY_ZONE='ZONE_" +
TABLE_NAME.toUpperCase() + "'");
+ + " (k int, v int, CONSTRAINT PK PRIMARY KEY (k)) ZONE ZONE_"
+ TABLE_NAME + " STORAGE PROFILE '"
+ + DEFAULT_AIMEM_PROFILE_NAME + "'");
}
/**
@@ -172,8 +172,8 @@ class ItRaftStorageVolatilityTest extends
ClusterPerTestIntegrationTest {
executeSql("CREATE TABLE " + TABLE_NAME
+ " (k int, v int, CONSTRAINT PK PRIMARY KEY (k)) "
- + "WITH STORAGE_PROFILE='" + DEFAULT_ROCKSDB_PROFILE_NAME +
"',"
- + "PRIMARY_ZONE='ZONE_" + TABLE_NAME.toUpperCase() + "'");
+ + "ZONE ZONE_" + TABLE_NAME.toUpperCase() + " "
+ + "STORAGE PROFILE '" + DEFAULT_ROCKSDB_PROFILE_NAME + "' ");
}
@Test
@@ -252,8 +252,8 @@ class ItRaftStorageVolatilityTest extends
ClusterPerTestIntegrationTest {
+ "storage_profiles = '" +
DEFAULT_AIMEM_PROFILE_NAME + "'"
);
session.execute(null, "create table " + tableName
- + " (id int primary key, name varchar) with
storage_profile='"
- + DEFAULT_AIMEM_PROFILE_NAME + "', primary_zone='ZONE1'");
+ + " (id int primary key, name varchar) zone ZONE1 storage
profile '"
+ + DEFAULT_AIMEM_PROFILE_NAME + "'");
});
}
}
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java
index 59fb29e842..6727fd667c 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java
@@ -366,7 +366,7 @@ public class ItIgniteInMemoryNodeRestartTest extends
BaseIgniteRestartTest {
name, replicas, partitions, DEFAULT_AIMEM_PROFILE_NAME));
sql.execute(null, "CREATE TABLE " + name
+ " (id INT PRIMARY KEY, name VARCHAR)"
- + " WITH PRIMARY_ZONE='ZONE_" + name.toUpperCase() + "';");
+ + " ZONE ZONE_" + name.toUpperCase() + ";");
for (int i = 0; i < 100; i++) {
sql.execute(null, "INSERT INTO " + name + "(id, name) VALUES (?,
?)",
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java
index d765f81b4b..57b44c78e5 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java
@@ -1651,8 +1651,7 @@ public class ItIgniteNodeRestartTest extends
BaseIgniteRestartTest {
sql.execute(null, String.format("CREATE ZONE IF NOT EXISTS %s WITH
REPLICAS=%d, PARTITIONS=%d, STORAGE_PROFILES='%s'",
zoneName, nodesCount, 1, DEFAULT_STORAGE_PROFILE));
- sql.execute(null, "CREATE TABLE " + TABLE_NAME
- + "(id INT PRIMARY KEY, name VARCHAR) WITH PRIMARY_ZONE='" +
zoneName + "';");
+ sql.execute(null, "CREATE TABLE " + TABLE_NAME + "(id INT PRIMARY KEY,
name VARCHAR) ZONE " + zoneName + ";");
assertEquals(TABLE_ID, tableId(node, TABLE_NAME));
@@ -1768,7 +1767,7 @@ public class ItIgniteNodeRestartTest extends
BaseIgniteRestartTest {
nodeInhibitor2.startInhibit();
sql.executeAsync(null, "CREATE TABLE " + tableName
- + "(id INT PRIMARY KEY, name VARCHAR) WITH PRIMARY_ZONE='" +
zoneName + "';");
+ + "(id INT PRIMARY KEY, name VARCHAR) ZONE " + zoneName + ";");
// Stopping 2 of 3 nodes.
node1.stop();
@@ -2081,7 +2080,7 @@ public class ItIgniteNodeRestartTest extends
BaseIgniteRestartTest {
String.format("CREATE ZONE IF NOT EXISTS ZONE_%s WITH
REPLICAS=%d, PARTITIONS=%d, STORAGE_PROFILES='%s'",
name, replicas, partitions, DEFAULT_STORAGE_PROFILE));
sql.execute(null, "CREATE TABLE IF NOT EXISTS " + name
- + "(id INT PRIMARY KEY, name VARCHAR) WITH
PRIMARY_ZONE='ZONE_" + name.toUpperCase() + "';");
+ + "(id INT PRIMARY KEY, name VARCHAR) ZONE ZONE_" + name +
";");
for (int i = 0; i < 100; i++) {
sql.execute(null, "INSERT INTO " + name + "(id, name) VALUES (?,
?)",
@@ -2104,7 +2103,7 @@ public class ItIgniteNodeRestartTest extends
BaseIgniteRestartTest {
String.format("CREATE ZONE IF NOT EXISTS ZONE_%s WITH
REPLICAS=%d, PARTITIONS=%d, STORAGE_PROFILES='%s'",
name, replicas, partitions, DEFAULT_STORAGE_PROFILE));
sql.execute(null, "CREATE TABLE " + name
- + "(id INT PRIMARY KEY, name VARCHAR) WITH
PRIMARY_ZONE='ZONE_" + name.toUpperCase() + "';");
+ + "(id INT PRIMARY KEY, name VARCHAR) ZONE ZONE_" + name +
";");
return ignite.tables().table(name);
}
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItReplicaStateManagerTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItReplicaStateManagerTest.java
index 3989e0b83c..6f2cd40ea4 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItReplicaStateManagerTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItReplicaStateManagerTest.java
@@ -78,7 +78,7 @@ public class ItReplicaStateManagerTest extends
BaseIgniteRestartTest {
ZONE_NAME, 3, 1, DEFAULT_STORAGE_PROFILE));
node0.sql().execute(null,
- String.format("CREATE TABLE IF NOT EXISTS %s (id INT PRIMARY
KEY, name VARCHAR) WITH PRIMARY_ZONE='%s'", tableName,
+ String.format("CREATE TABLE IF NOT EXISTS %s (id INT PRIMARY
KEY, name VARCHAR) ZONE %s", tableName,
ZONE_NAME
)
);
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
index d6a0c37118..2cb4f685af 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
@@ -124,7 +124,7 @@ public abstract class ItAbstractThinClientTest extends
BaseIgniteAbstractTest {
sql.execute(null, "CREATE ZONE TEST_ZONE WITH REPLICAS=1,
PARTITIONS=10, STORAGE_PROFILES='"
+ DEFAULT_STORAGE_PROFILE + "'");
sql.execute(null, "CREATE TABLE " + TABLE_NAME + "("
- + COLUMN_KEY + " INT PRIMARY KEY, " + COLUMN_VAL + " VARCHAR)
WITH PRIMARY_ZONE='TEST_ZONE'");
+ + COLUMN_KEY + " INT PRIMARY KEY, " + COLUMN_VAL + " VARCHAR)
ZONE TEST_ZONE");
client =
IgniteClient.builder().addresses(getClientAddresses().toArray(new
String[0])).build();
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncAndReplicationTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncAndReplicationTest.java
index 6787ae5829..97aaf9a92e 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncAndReplicationTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncAndReplicationTest.java
@@ -107,7 +107,7 @@ class ItSchemaSyncAndReplicationTest extends
ClusterPerTestIntegrationTest {
private void createTestTableWith3Replicas() {
String zoneSql = "create zone test_zone with partitions=1, replicas=3,
storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'";
String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20))"
- + " with primary_zone='TEST_ZONE'";
+ + " zone TEST_ZONE";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncMultiNodeTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncMultiNodeTest.java
index a6710e0c55..77253fe103 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncMultiNodeTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncMultiNodeTest.java
@@ -186,7 +186,7 @@ class ItSchemaSyncMultiNodeTest extends
ClusterPerTestIntegrationTest {
});
CompletableFuture<Void> tableCreationFuture = runAsync(() ->
cluster.doInSession(NODE_1_INDEX, session -> {
- executeUpdate("CREATE TABLE " + TABLE_NAME + " (id int PRIMARY
KEY, val varchar) WITH primary_zone='TEST_ZONE'", session);
+ executeUpdate("CREATE TABLE " + TABLE_NAME + " (id int PRIMARY
KEY, val varchar) ZONE TEST_ZONE", session);
}));
assertThat(tableCreationFuture, willTimeoutIn(1, SECONDS));
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
index 82f413da33..0b7fc2c4a0 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
@@ -82,7 +82,7 @@ public class ItDurableFinishTest extends
ClusterPerTestIntegrationTest {
private void createTestTableWith3Replicas() {
String zoneSql = "create zone test_zone with partitions=1, replicas=3,
storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'";
String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20))"
- + " with primary_zone='TEST_ZONE'";
+ + " zone TEST_ZONE";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItInternalTableTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItInternalTableTest.java
index 7ebbe47f79..a657a20857 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItInternalTableTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItInternalTableTest.java
@@ -643,13 +643,13 @@ public class ItInternalTableTest extends
ClusterPerClassIntegrationTest {
String zoneName = zoneNameForTable(tableName);
IgniteSql sql = node.sql();
- sql.execute(null, String.format("create zone \"%s\" with partitions=3,
replicas=%d, storage_profiles='%s'",
+ sql.execute(null, String.format("create zone %s with partitions=3,
replicas=%d, storage_profiles='%s'",
zoneName, DEFAULT_REPLICA_COUNT, DEFAULT_STORAGE_PROFILE));
sql.execute(null,
String.format(
- "create table \"%s\" (key bigint primary key, valInt
int, valStr varchar default 'default') "
- + "with primary_zone='%s'",
+ "create table %s (key bigint primary key, valInt int,
valStr varchar default 'default') "
+ + "zone %s",
tableName, zoneName
)
);
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
index a25e0b0478..3f31028a53 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
@@ -68,7 +68,7 @@ public class ItReadOnlyTransactionTest extends
ClusterPerClassIntegrationTest {
public void beforeEach() {
sql(IgniteStringFormatter.format("CREATE ZONE IF NOT EXISTS {} WITH
REPLICAS={}, PARTITIONS={}, STORAGE_PROFILES='{}';",
ZONE_NAME, initialNodes(), 10, DEFAULT_STORAGE_PROFILE));
- sql(IgniteStringFormatter.format("CREATE TABLE {}(id INT PRIMARY KEY,
val VARCHAR) WITH PRIMARY_ZONE='{}'",
+ sql(IgniteStringFormatter.format("CREATE TABLE {}(id INT PRIMARY KEY,
val VARCHAR) ZONE {}",
TABLE_NAME, ZONE_NAME));
Ignite ignite = CLUSTER.aliveNode();
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java
index 7aec095b77..9a058af9c4 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java
@@ -36,7 +36,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -75,6 +74,7 @@ import
org.apache.ignite.internal.storage.index.impl.TestSortedIndexStorage;
import org.apache.ignite.internal.testframework.IgniteTestUtils;
import org.apache.ignite.internal.tx.InternalTransaction;
import org.apache.ignite.internal.utils.PrimaryReplica;
+import org.apache.ignite.lang.ErrorGroups.Transactions;
import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.table.KeyValueView;
import org.apache.ignite.table.Tuple;
@@ -531,8 +531,12 @@ public class ItTableScanTest extends
BaseSqlIntegrationTest {
assertFalse(scanned.isDone());
- assertThrows(TransactionException.class,
- () -> kvView.put(null, Tuple.create().set("key", 3),
Tuple.create().set("valInt", 3).set("valStr", "New_3")));
+ IgniteTestUtils.assertThrowsWithCode(
+ TransactionException.class,
+ Transactions.ACQUIRE_LOCK_ERR,
+ () -> kvView.put(null, Tuple.create().set("key", 3),
Tuple.create().set("valInt", 3).set("valStr", "New_3")),
+ "Failed to acquire a lock due to a possible deadlock"
+ );
kvView.put(null, Tuple.create().set("key", 8),
Tuple.create().set("valInt", 8).set("valStr", "New_8"));
@@ -606,10 +610,16 @@ public class ItTableScanTest extends
BaseSqlIntegrationTest {
assertEquals(3, scannedRows.size());
- assertThrows(TransactionException.class, () ->
- kvView.put(null, Tuple.create().set("key", 8),
Tuple.create().set("valInt", 8).set("valStr", "New_8")));
- assertThrows(TransactionException.class, () ->
- kvView.put(null, Tuple.create().set("key", 9),
Tuple.create().set("valInt", 9).set("valStr", "New_9")));
+ IgniteTestUtils.assertThrowsWithCode(
+ TransactionException.class,
+ Transactions.ACQUIRE_LOCK_ERR,
+ () -> kvView.put(null, Tuple.create().set("key", 8),
Tuple.create().set("valInt", 8).set("valStr", "New_8")),
+ "Failed to acquire a lock due to a possible deadlock");
+ IgniteTestUtils.assertThrowsWithCode(
+ TransactionException.class,
+ Transactions.ACQUIRE_LOCK_ERR,
+ () -> kvView.put(null, Tuple.create().set("key", 9),
Tuple.create().set("valInt", 9).set("valStr", "New_9")),
+ "Failed to acquire a lock due to a possible deadlock");
Publisher<BinaryRow> publisher1 = new RollbackTxOnErrorPublisher<>(
tx,
@@ -949,7 +959,7 @@ public class ItTableScanTest extends BaseSqlIntegrationTest
{
sql("CREATE ZONE IF NOT EXISTS ZONE1 WITH REPLICAS=1, PARTITIONS=1,
STORAGE_PROFILES='test'");
sql("CREATE TABLE IF NOT EXISTS " + TABLE_NAME
- + " (key INTEGER PRIMARY KEY, valInt INTEGER NOT NULL, valStr
VARCHAR NOT NULL) WITH PRIMARY_ZONE='ZONE1';");
+ + " (key INTEGER PRIMARY KEY, valInt INTEGER NOT NULL, valStr
VARCHAR NOT NULL) ZONE ZONE1;");
sql("CREATE INDEX IF NOT EXISTS " + SORTED_IDX + " ON " + TABLE_NAME +
" USING SORTED (valInt)");
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/partition/ItAbstractPartitionManagerTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/partition/ItAbstractPartitionManagerTest.java
index afe378df66..9bb7550a92 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/partition/ItAbstractPartitionManagerTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/partition/ItAbstractPartitionManagerTest.java
@@ -63,7 +63,7 @@ public abstract class ItAbstractPartitionManagerTest extends
ClusterPerTestInteg
+ " replicas=3,"
+ " storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'";
- String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) with primary_zone='" + ZONE_NAME + "'";
+ String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) zone " + ZONE_NAME;
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
diff --git
a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java
b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java
index cce77d852a..86cf57ed14 100644
---
a/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java
+++
b/modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java
@@ -192,7 +192,7 @@ public abstract class ClusterPerClassIntegrationTest
extends BaseIgniteAbstractT
*/
protected static Table createTableOnly(String tableName, String zoneName) {
sql(format(
- "CREATE TABLE IF NOT EXISTS {} (id INT PRIMARY KEY, name
VARCHAR, salary DOUBLE) WITH PRIMARY_ZONE='{}'",
+ "CREATE TABLE IF NOT EXISTS {} (id INT PRIMARY KEY, name
VARCHAR, salary DOUBLE) ZONE \"{}\"",
tableName, zoneName
));
diff --git
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItAggregatesTest.java
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItAggregatesTest.java
index 94d71043d8..74287ce36e 100644
---
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItAggregatesTest.java
+++
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItAggregatesTest.java
@@ -68,7 +68,7 @@ public class ItAggregatesTest extends BaseSqlIntegrationTest {
createAndPopulateTable();
sql("CREATE ZONE test_zone with replicas=2, partitions=10,
storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'");
- sql("CREATE TABLE test (id INT PRIMARY KEY, grp0 INT, grp1 INT, val0
INT, val1 INT) WITH PRIMARY_ZONE='TEST_ZONE'");
+ sql("CREATE TABLE test (id INT PRIMARY KEY, grp0 INT, grp1 INT, val0
INT, val1 INT) ZONE TEST_ZONE");
sql("CREATE TABLE test_one_col_idx (pk INT PRIMARY KEY, col0 INT)");
for (int i = 0; i < ROWS; i++) {
diff --git
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java
index 3821d7fd2c..3f50938557 100644
---
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java
+++
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java
@@ -368,32 +368,25 @@ public class ItCreateTableDdlTest extends
BaseSqlIntegrationTest {
@Test
public void testSuccessfulCreateTableWithZoneIdentifier() {
sql("CREATE ZONE test_zone WITH STORAGE_PROFILES='" +
DEFAULT_STORAGE_PROFILE + "'");
- sql("CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE=test_zone");
- }
-
- @Test
- public void testSuccessfulCreateTableWithZoneLiteral() {
- sql("CREATE ZONE test_zone WITH STORAGE_PROFILES='" +
DEFAULT_STORAGE_PROFILE + "'");
- sql("CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE='TEST_ZONE'");
+ sql("CREATE TABLE test_table (id INT PRIMARY KEY, val INT) ZONE
test_zone");
}
@Test
public void testSuccessfulCreateTableWithZoneQuotedLiteral() {
sql("CREATE ZONE \"test_zone\" WITH STORAGE_PROFILES='" +
DEFAULT_STORAGE_PROFILE + "'");
- sql("CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE='test_zone'");
+ sql("CREATE TABLE test_table (id INT PRIMARY KEY, val INT) ZONE
\"test_zone\"");
sql("DROP TABLE test_table");
sql("DROP ZONE \"test_zone\"");
}
@Test
public void testExceptionalCreateTableWithZoneUnquotedLiteral() {
-
sql("CREATE ZONE test_zone WITH STORAGE_PROFILES='" +
DEFAULT_STORAGE_PROFILE + "'");
assertThrowsSqlException(
SqlException.class,
STMT_VALIDATION_ERR,
"Failed to validate query. Distribution zone with name
'test_zone' not found",
- () -> sql("CREATE TABLE test_table (id INT PRIMARY KEY, val
INT) WITH PRIMARY_ZONE='test_zone'"));
+ () -> sql("CREATE TABLE test_table (id INT PRIMARY KEY, val
INT) ZONE \"test_zone\""));
}
@Test
@@ -416,13 +409,13 @@ public class ItCreateTableDdlTest extends
BaseSqlIntegrationTest {
assertThrowsSqlException(
STMT_VALIDATION_ERR,
"Zone with name '" + defaultZoneName + "' does not contain
table's storage profile",
- () -> sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT)
WITH STORAGE_PROFILE='profile1'")
+ () -> sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT)
STORAGE PROFILE 'profile1'")
);
}
@Test
public void tableStorageProfile() {
- sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT) WITH
STORAGE_PROFILE='" + DEFAULT_STORAGE_PROFILE + "'");
+ sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT) STORAGE PROFILE
'" + DEFAULT_STORAGE_PROFILE + "'");
IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode());
@@ -439,7 +432,7 @@ public class ItCreateTableDdlTest extends
BaseSqlIntegrationTest {
public void tableStorageProfileWithCustomZoneDefaultProfile() {
sql("CREATE ZONE ZONE1 WITH PARTITIONS = 1, STORAGE_PROFILES = '" +
DEFAULT_STORAGE_PROFILE + "'");
- sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT) WITH
PRIMARY_ZONE='ZONE1'");
+ sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT) ZONE ZONE1");
IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode());
@@ -456,7 +449,7 @@ public class ItCreateTableDdlTest extends
BaseSqlIntegrationTest {
public void tableStorageProfileWithCustomZoneExplicitProfile() {
sql("CREATE ZONE ZONE1 WITH PARTITIONS = 1, STORAGE_PROFILES = '" +
DEFAULT_STORAGE_PROFILE + "'");
- sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT) WITH
PRIMARY_ZONE='ZONE1', STORAGE_PROFILE='" + DEFAULT_STORAGE_PROFILE + "'");
+ sql("CREATE TABLE TEST(ID INT PRIMARY KEY, VAL0 INT) ZONE ZONE1
STORAGE PROFILE '" + DEFAULT_STORAGE_PROFILE + "'");
IgniteImpl node = unwrapIgniteImpl(CLUSTER.aliveNode());
@@ -570,7 +563,7 @@ public class ItCreateTableDdlTest extends
BaseSqlIntegrationTest {
String tableName = "test_table";
sql("CREATE ZONE test_zone WITH STORAGE_PROFILES='no-such-profile'");
- sql("CREATE TABLE " + tableName + " (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE=test_zone");
+ sql("CREATE TABLE " + tableName + " (id INT PRIMARY KEY, val INT) ZONE
test_zone");
Table table = CLUSTER.aliveNode().tables().table(tableName);
assertThat(table, is(notNullValue()));
diff --git
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java
index 7c8a206ad7..52bbc4b5f9 100644
---
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java
+++
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItIndexSpoolTest.java
@@ -104,8 +104,8 @@ public class ItIndexSpoolTest extends
BaseSqlIntegrationTest {
parts,
DEFAULT_STORAGE_PROFILE
));
- sql(String.format("CREATE TABLE %s(id INT PRIMARY KEY, jid INT,
val VARCHAR) WITH PRIMARY_ZONE='%s'",
- name, "ZONE_" + name.toUpperCase()));
+ sql(String.format("CREATE TABLE %s(id INT PRIMARY KEY, jid INT,
val VARCHAR) ZONE %s",
+ name, "ZONE_" + name));
sql("CREATE INDEX " + name + "_jid_idx ON " + name + "(jid)");
diff --git
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
index 96a1fe4bce..03a36e785e 100644
---
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
+++
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
@@ -81,7 +81,7 @@ public class ItPkOnlyTableCrossApiTest extends
BaseSqlIntegrationTest {
testZoneName, regionName, regionName));
sql(String.format(
- "create table %s (ID int, NAME varchar, primary key(ID,
NAME)) with primary_zone='%s', storage_profile='%s'",
+ "create table %s (ID int, NAME varchar, primary key(ID,
NAME)) zone %s storage profile '%s'",
tableName(engine),
testZoneName,
regionName
diff --git
a/modules/sql-engine/src/integrationTest/sql/set/test_basic_union.test
b/modules/sql-engine/src/integrationTest/sql/set/test_basic_union.test
index c3d42174bc..d97aa61f94 100644
--- a/modules/sql-engine/src/integrationTest/sql/set/test_basic_union.test
+++ b/modules/sql-engine/src/integrationTest/sql/set/test_basic_union.test
@@ -131,7 +131,5 @@ SELECT 1, 2 UNION ALL SELECT 1, 2, 3
statement error: Type mismatch in column 1 of UNION ALL
SELECT 'abcd' UNION ALL SELECT '2000-11-02'::DATE
-skipif ignite3
-# https://issues.apache.org/jira/browse/IGNITE-22358
statement error: Type mismatch in column 1 of UNION ALL
SELECT 1 UNION ALL SELECT '2000-11-02'::DATE
diff --git a/modules/sql-engine/src/main/codegen/config.fmpp
b/modules/sql-engine/src/main/codegen/config.fmpp
index ee8310be2e..f1ccd76678 100644
--- a/modules/sql-engine/src/main/codegen/config.fmpp
+++ b/modules/sql-engine/src/main/codegen/config.fmpp
@@ -39,7 +39,6 @@ data: {
"org.apache.ignite.internal.sql.engine.sql.IgniteSqlAlterColumn",
"org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateTable",
"org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateIndex",
- "org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateTableOption",
"org.apache.ignite.internal.sql.engine.sql.IgniteSqlPrimaryKeyConstraint",
"org.apache.ignite.internal.sql.engine.sql.IgniteSqlPrimaryKeyIndexType",
"org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateZone",
@@ -66,6 +65,8 @@ data: {
# not a reserved keyword, add it to the 'nonReservedKeywords' section.
keywords: [
"COLOCATE"
+ "STORAGE"
+ "PROFILE"
"IF"
"INDEX"
"ENGINE"
@@ -84,6 +85,8 @@ data: {
nonReservedKeywordsToAdd: [
# Keywords introduced by Ignite
"ENGINE"
+ "STORAGE"
+ "PROFILE"
"SORTED"
"HASH"
"UUID"
diff --git a/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
b/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
index 1be45d4c2b..de8180fc4b 100644
--- a/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
+++ b/modules/sql-engine/src/main/codegen/includes/parserImpls.ftl
@@ -24,40 +24,6 @@ boolean IfNotExistsOpt() :
{ return false; }
}
-SqlNodeList CreateTableOptionList() :
-{
- List<SqlNode> list = new ArrayList<SqlNode>();
- final Span s = Span.of();
-}
-{
- CreateTableOption(list)
- (
- <COMMA> { s.add(this); } CreateTableOption(list)
- )*
- {
- return new SqlNodeList(list, s.end(this));
- }
-}
-
-void CreateTableOption(List<SqlNode> list) :
-{
- final Span s;
- final SqlIdentifier key;
- final SqlNode val;
-}
-{
- key = SimpleIdentifier() { s = span(); }
- <EQ>
- (
- val = Literal()
- |
- val = SimpleIdentifier()
- )
- {
- list.add(new IgniteSqlCreateTableOption(key, val, s.end(this)));
- }
-}
-
SqlDataTypeSpec DataTypeEx(Span s, boolean allowCharType) :
{
final SqlDataTypeSpec dt;
@@ -206,7 +172,8 @@ SqlCreate SqlCreateTable(Span s, boolean replace) :
final boolean ifNotExists;
final SqlIdentifier id;
final SqlNodeList columnList;
- SqlNodeList optionList = null;
+ SqlIdentifier zoneName = null;
+ SqlNode storageProfile = null;
SqlNodeList colocationColumns = null;
}
{
@@ -219,10 +186,13 @@ SqlCreate SqlCreateTable(Span s, boolean replace) :
colocationColumns = ParenthesizedSimpleIdentifierList()
]
[
- <WITH> { s.add(this); } optionList = CreateTableOptionList()
+ <ZONE> {s.add(this);} zoneName = SimpleIdentifier()
+ ]
+ [
+ <STORAGE> <PROFILE> {s.add(this);} storageProfile = StringLiteral()
]
{
- return new IgniteSqlCreateTable(s.end(this), ifNotExists, id,
columnList, colocationColumns, optionList);
+ return new IgniteSqlCreateTable(s.end(this), ifNotExists, id,
columnList, colocationColumns, zoneName, storageProfile);
}
}
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java
index df1942d700..31e9676f43 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java
@@ -23,8 +23,6 @@ import static
org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_L
import static
org.apache.ignite.internal.catalog.commands.CatalogUtils.defaultLength;
import static
org.apache.ignite.internal.distributionzones.DistributionZonesUtil.parseStorageProfiles;
import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
-import static
org.apache.ignite.internal.sql.engine.prepare.ddl.TableOptionEnum.PRIMARY_ZONE;
-import static
org.apache.ignite.internal.sql.engine.prepare.ddl.TableOptionEnum.STORAGE_PROFILE;
import static
org.apache.ignite.internal.sql.engine.prepare.ddl.ZoneOptionEnum.DATA_NODES_AUTO_ADJUST;
import static
org.apache.ignite.internal.sql.engine.prepare.ddl.ZoneOptionEnum.DATA_NODES_AUTO_ADJUST_SCALE_DOWN;
import static
org.apache.ignite.internal.sql.engine.prepare.ddl.ZoneOptionEnum.DATA_NODES_AUTO_ADJUST_SCALE_UP;
@@ -121,7 +119,6 @@ import
org.apache.ignite.internal.sql.engine.sql.IgniteSqlAlterZoneSet;
import org.apache.ignite.internal.sql.engine.sql.IgniteSqlAlterZoneSetDefault;
import org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateIndex;
import org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateTable;
-import org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateTableOption;
import org.apache.ignite.internal.sql.engine.sql.IgniteSqlCreateZone;
import org.apache.ignite.internal.sql.engine.sql.IgniteSqlDropIndex;
import org.apache.ignite.internal.sql.engine.sql.IgniteSqlDropTable;
@@ -143,9 +140,6 @@ import org.jetbrains.annotations.Nullable;
* Converts the DDL AST tree to the appropriate catalog command.
*/
public class DdlSqlToCommandConverter {
- /** Mapping: Table option ID -> DDL option info. */
- private final Map<TableOptionEnum,
DdlOptionInfo<CreateTableCommandBuilder, ?>> tableOptionInfos;
-
/** Mapping: Zone option ID -> DDL option info. */
private final Map<ZoneOptionEnum, DdlOptionInfo<CreateZoneCommandBuilder,
?>> zoneOptionInfos;
@@ -164,11 +158,6 @@ public class DdlSqlToCommandConverter {
.map(Enum::name)
.collect(Collectors.toSet());
- this.tableOptionInfos = new EnumMap<>(Map.of(
- PRIMARY_ZONE, new DdlOptionInfo<>(String.class, null,
CreateTableCommandBuilder::zone),
- STORAGE_PROFILE, new DdlOptionInfo<>(String.class,
this::checkEmptyString, CreateTableCommandBuilder::storageProfile)
- ));
-
// CREATE ZONE options.
zoneOptionInfos = new EnumMap<>(Map.of(
REPLICAS, new DdlOptionInfo<>(Integer.class,
this::checkPositiveNumber, CreateZoneCommandBuilder::replicas),
@@ -267,25 +256,6 @@ public class DdlSqlToCommandConverter {
private CatalogCommand convertCreateTable(IgniteSqlCreateTable
createTblNode, PlanningContext ctx) {
CreateTableCommandBuilder tblBuilder = CreateTableCommand.builder();
- if (createTblNode.createOptionList() != null) {
- for (SqlNode optionNode :
createTblNode.createOptionList().getList()) {
- IgniteSqlCreateTableOption option =
(IgniteSqlCreateTableOption) optionNode;
-
- assert option.key().isSimple() : option.key();
-
- String optionKey = option.key().getSimple().toUpperCase();
-
- try {
- DdlOptionInfo<CreateTableCommandBuilder, ?> tblOptionInfo
= tableOptionInfos.get(TableOptionEnum.valueOf(optionKey));
-
- updateCommandOption("Table", optionKey, option.value(),
tblOptionInfo, ctx.query(), tblBuilder);
- } catch (IllegalArgumentException ignored) {
- throw new SqlException(
- STMT_VALIDATION_ERR, format("Unexpected table
option [option={}, query={}]", optionKey, ctx.query()));
- }
- }
- }
-
List<IgniteSqlPrimaryKeyConstraint> pkConstraints =
createTblNode.columnList().getList().stream()
.filter(IgniteSqlPrimaryKeyConstraint.class::isInstance)
.map(IgniteSqlPrimaryKeyConstraint.class::cast)
@@ -381,11 +351,23 @@ public class DdlSqlToCommandConverter {
columns.add(convertColumnDeclaration(col, ctx.planner(),
!pkColumns.contains(col.name.getSimple())));
}
+ String storageProfile = null;
+ if (createTblNode.storageProfile() != null) {
+ assert createTblNode.storageProfile().getKind() == SqlKind.LITERAL;
+
+ storageProfile = ((SqlLiteral)
createTblNode.storageProfile()).getValueAs(String.class);
+ checkEmptyString(storageProfile);
+ }
+
+ String zone = createTblNode.zone() == null ? null :
createTblNode.zone().getSimple();
+
return tblBuilder.schemaName(deriveSchemaName(createTblNode.name(),
ctx))
.tableName(deriveObjectName(createTblNode.name(), ctx,
"tableName"))
.columns(columns)
.primaryKey(primaryKey)
.colocationColumns(colocationColumns)
+ .zone(zone)
+ .storageProfile(storageProfile)
.ifTableExists(createTblNode.ifNotExists())
.build();
}
@@ -854,7 +836,7 @@ public class DdlSqlToCommandConverter {
}
private void checkEmptyString(String string) {
- if (string.isEmpty()) {
+ if (string.isBlank()) {
throw new SqlException(STMT_VALIDATION_ERR, "String cannot be
empty");
}
}
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTable.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTable.java
index 68cdfdb86e..16ba7f021a 100644
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTable.java
+++
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTable.java
@@ -49,18 +49,18 @@ public class IgniteSqlCreateTable extends SqlCreate {
public SqlCall createCall(@Nullable SqlLiteral functionQualifier,
SqlParserPos pos,
@Nullable SqlNode... operands) {
return new IgniteSqlCreateTable(pos, existFlag(), (SqlIdentifier)
operands[0], (SqlNodeList) operands[1],
- (SqlNodeList) operands[2], (SqlNodeList) operands[3]);
+ (SqlNodeList) operands[2], (SqlIdentifier) operands[3],
(SqlLiteral) operands[4]);
}
}
private final SqlIdentifier name;
+ private final @Nullable SqlIdentifier zone;
+ private final @Nullable SqlNode storageProfile;
private final @Nullable SqlNodeList columnList;
private final @Nullable SqlNodeList colocationColumns;
- private final @Nullable SqlNodeList createOptionList;
-
/** Creates a SqlCreateTable. */
public IgniteSqlCreateTable(
SqlParserPos pos,
@@ -68,14 +68,16 @@ public class IgniteSqlCreateTable extends SqlCreate {
SqlIdentifier name,
@Nullable SqlNodeList columnList,
@Nullable SqlNodeList colocationColumns,
- @Nullable SqlNodeList createOptionList
+ @Nullable SqlIdentifier zone,
+ @Nullable SqlNode storageProfile
) {
super(new Operator(ifNotExists), pos, false, ifNotExists);
this.name = Objects.requireNonNull(name, "name");
this.columnList = columnList;
this.colocationColumns = colocationColumns;
- this.createOptionList = createOptionList;
+ this.zone = zone;
+ this.storageProfile = storageProfile;
}
/** {@inheritDoc} */
@@ -88,7 +90,7 @@ public class IgniteSqlCreateTable extends SqlCreate {
@SuppressWarnings("nullness")
@Override
public List<SqlNode> getOperandList() {
- return ImmutableNullableList.of(name, columnList, colocationColumns,
createOptionList);
+ return ImmutableNullableList.of(name, columnList, colocationColumns,
zone, storageProfile);
}
/** {@inheritDoc} */
@@ -118,10 +120,14 @@ public class IgniteSqlCreateTable extends SqlCreate {
writer.endList(frame);
}
- if (createOptionList != null) {
- writer.keyword("WITH");
+ if (zone != null) {
+ writer.keyword("ZONE");
+ zone.unparse(writer, leftPrec, rightPrec);
+ }
- createOptionList.unparse(writer, 0, 0);
+ if (storageProfile != null) {
+ writer.keyword("STORAGE PROFILE");
+ storageProfile.unparse(writer, leftPrec, rightPrec);
}
}
@@ -147,10 +153,17 @@ public class IgniteSqlCreateTable extends SqlCreate {
}
/**
- * Get list of the specified options to create table with.
+ * Get zone identifier to create the table.
+ */
+ public @Nullable SqlIdentifier zone() {
+ return zone;
+ }
+
+ /**
+ * Get storage profile identifier to create teh table.
*/
- public SqlNodeList createOptionList() {
- return createOptionList;
+ public @Nullable SqlNode storageProfile() {
+ return storageProfile;
}
/**
diff --git
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTableOption.java
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTableOption.java
deleted file mode 100644
index 27c59da3fd..0000000000
---
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlCreateTableOption.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.sql.engine.sql;
-
-import java.util.List;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlIdentifier;
-import org.apache.calcite.sql.SqlKind;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.sql.SqlNode;
-import org.apache.calcite.sql.SqlOperator;
-import org.apache.calcite.sql.SqlWriter;
-import org.apache.calcite.sql.parser.SqlParserPos;
-import org.apache.calcite.util.Litmus;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/** An AST node representing option to create table with. */
-public class IgniteSqlCreateTableOption extends SqlCall {
-
- /** Table option. */
- protected static class Operator extends IgniteSqlSpecialOperator {
-
- /** Constructor. */
- protected Operator() {
- super("TableOption", SqlKind.OTHER);
- }
-
- /** {@inheritDoc} */
- @Override
- public SqlCall createCall(@Nullable SqlLiteral functionQualifier,
SqlParserPos pos, @Nullable SqlNode... operands) {
- return new IgniteSqlCreateTableOption((SqlIdentifier) operands[0],
operands[1], pos);
- }
- }
-
- private static final SqlOperator OPERATOR = new Operator();
-
- /** Option key. */
- private final SqlIdentifier key;
-
- /** Option value. */
- private final SqlNode value;
-
- /** Creates IgniteSqlCreateTableOption. */
- public IgniteSqlCreateTableOption(SqlIdentifier key, SqlNode value,
SqlParserPos pos) {
- super(pos);
-
- this.key = key;
- this.value = value;
- }
-
- /** {@inheritDoc} */
- @Override
- public SqlOperator getOperator() {
- return OPERATOR;
- }
-
- /** {@inheritDoc} */
- @Override
- public List<SqlNode> getOperandList() {
- return List.of(key, value);
- }
-
- /** {@inheritDoc} */
- @Override
- public SqlNode clone(SqlParserPos pos) {
- return new IgniteSqlCreateTableOption(key, value, pos);
- }
-
- /** {@inheritDoc} */
- @Override
- public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
- key.unparse(writer, leftPrec, rightPrec);
- writer.keyword("=");
- value.unparse(writer, leftPrec, rightPrec);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equalsDeep(SqlNode node, Litmus litmus) {
- if (!(node instanceof IgniteSqlCreateTableOption)) {
- return litmus.fail("{} != {}", this, node);
- }
-
- IgniteSqlCreateTableOption that = (IgniteSqlCreateTableOption) node;
- if (key != that.key) {
- return litmus.fail("{} != {}", this, node);
- }
-
- return value.equalsDeep(that.value, litmus);
- }
-
- /**
- * Get option's key.
- */
- public SqlIdentifier key() {
- return key;
- }
-
- /**
- * Get option's value.
- */
- public SqlNode value() {
- return value;
- }
-}
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverterTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverterTest.java
index 8aec04ba97..3d86180474 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverterTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverterTest.java
@@ -29,23 +29,21 @@ import static
org.apache.ignite.internal.distributionzones.DistributionZonesUtil
import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
import static
org.apache.ignite.internal.sql.engine.util.SqlTestUtils.assertThrowsSqlException;
import static
org.apache.ignite.internal.sql.engine.util.TypeUtils.fromInternal;
+import static
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
import static org.apache.ignite.lang.ErrorGroups.Sql.STMT_VALIDATION_ERR;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import java.math.BigDecimal;
import java.time.Duration;
@@ -62,8 +60,10 @@ import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.SqlDdl;
+import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.parser.SqlParseException;
import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.ignite.internal.catalog.CatalogCommand;
import org.apache.ignite.internal.catalog.commands.CreateTableCommand;
import org.apache.ignite.internal.catalog.commands.DefaultValue;
import org.apache.ignite.internal.catalog.commands.DefaultValue.ConstantValue;
@@ -82,7 +82,6 @@ import
org.apache.ignite.internal.sql.engine.prepare.PlanningContext;
import org.apache.ignite.internal.sql.engine.util.Commons;
import org.apache.ignite.internal.sql.engine.util.SqlTestUtils;
import org.apache.ignite.internal.testframework.WithSystemProperty;
-import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.sql.ColumnType;
import org.hamcrest.CustomMatcher;
import org.hamcrest.Matcher;
@@ -106,16 +105,15 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
@Test
void testCheckDuplicates() {
- IllegalStateException exception = assertThrows(
+ assertThrows(
IllegalStateException.class,
() -> checkDuplicates(
Set.of("replicas", "partitionDistribution"),
Set.of("partitions", "replicas")
- )
+ ),
+ "Duplicate id: replicas"
);
- assertThat(exception.getMessage(), startsWith("Duplicate id:
replicas"));
-
assertDoesNotThrow(() -> checkDuplicates(
Set.of("replicas", "partitionDistribution"),
Set.of("replicas0", "partitionDistribution0")
@@ -125,41 +123,39 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
@Test
public void tableWithoutPkShouldThrowErrorWhenSysPropDefault() throws
SqlParseException {
- var node = parse("CREATE TABLE t (val int) WITH STORAGE_PROFILE='" +
DEFAULT_STORAGE_PROFILE + "'");
+ SqlNode node = parse("CREATE TABLE t (val int) STORAGE PROFILE '" +
DEFAULT_STORAGE_PROFILE + "'");
assertThat(node, instanceOf(SqlDdl.class));
- var ex = assertThrows(
- IgniteException.class,
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Table without PRIMARY KEY is not supported",
() -> converter.convert((SqlDdl) node, createContext())
);
-
- assertThat(ex.getMessage(), containsString("Table without PRIMARY KEY
is not supported"));
}
@Test
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "false")
public void tableWithoutPkShouldThrowErrorWhenSysPropDisabled() throws
SqlParseException {
- var node = parse("CREATE TABLE t (val int) WITH STORAGE_PROFILE='" +
DEFAULT_STORAGE_PROFILE + "'");
+ SqlNode node = parse("CREATE TABLE t (val int) STORAGE PROFILE '" +
DEFAULT_STORAGE_PROFILE + "'");
assertThat(node, instanceOf(SqlDdl.class));
- var ex = assertThrows(
- IgniteException.class,
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Table without PRIMARY KEY is not supported",
() -> converter.convert((SqlDdl) node, createContext())
);
-
- assertThat(ex.getMessage(), containsString("Table without PRIMARY KEY
is not supported"));
}
@Test
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public void tableWithoutPkShouldInjectImplicitPkWhenSysPropEnabled()
throws SqlParseException {
- var node = parse("CREATE TABLE t (val int) WITH STORAGE_PROFILE='" +
DEFAULT_STORAGE_PROFILE + "'");
+ SqlNode node = parse("CREATE TABLE t (val int) STORAGE PROFILE '" +
DEFAULT_STORAGE_PROFILE + "'");
assertThat(node, instanceOf(SqlDdl.class));
- var cmd = converter.convert((SqlDdl) node, createContext());
+ CatalogCommand cmd = converter.convert((SqlDdl) node, createContext());
assertThat(cmd, Matchers.instanceOf(CreateTableCommand.class));
@@ -202,11 +198,11 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
})
public void tableWithSortedPk(String sqlCol, CatalogColumnCollation
collation) throws SqlParseException {
String query = format("CREATE TABLE t (id int, val int, PRIMARY KEY
USING SORTED (id {}))", sqlCol);
- var node = parse(query);
+ SqlNode node = parse(query);
assertThat(node, instanceOf(SqlDdl.class));
- var cmd = converter.convert((SqlDdl) node, createContext());
+ CatalogCommand cmd = converter.convert((SqlDdl) node, createContext());
assertThat(cmd, Matchers.instanceOf(CreateTableCommand.class));
@@ -231,7 +227,7 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
"CREATE TABLE t (c1 int, c2 int, c3 int, PRIMARY KEY (c1), PRIMARY
KEY (c2) )",
})
public void tablePkAppearsOnlyOnce(String stmt) throws SqlParseException {
- var node = parse(stmt);
+ SqlNode node = parse(stmt);
assertThat(node, instanceOf(SqlDdl.class));
assertThrowsSqlException(STMT_VALIDATION_ERR,
@@ -242,11 +238,11 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
@Test
public void tableWithHashPk() throws SqlParseException {
- var node = parse("CREATE TABLE t (id int, val int, PRIMARY KEY USING
HASH (id))");
+ SqlNode node = parse("CREATE TABLE t (id int, val int, PRIMARY KEY
USING HASH (id))");
assertThat(node, instanceOf(SqlDdl.class));
- var cmd = converter.convert((SqlDdl) node, createContext());
+ CatalogCommand cmd = converter.convert((SqlDdl) node, createContext());
assertThat(cmd, Matchers.instanceOf(CreateTableCommand.class));
@@ -267,11 +263,11 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
@Test
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public void tableWithIdentifierZone() throws SqlParseException {
- var node = parse("CREATE TABLE t (id int) WITH
PRIMARY_ZONE=test_zone");
+ SqlNode node = parse("CREATE TABLE t (id int) ZONE test_zone");
assertThat(node, instanceOf(SqlDdl.class));
- var cmd = converter.convert((SqlDdl) node, createContext());
+ CatalogCommand cmd = converter.convert((SqlDdl) node, createContext());
assertThat(cmd, Matchers.instanceOf(CreateTableCommand.class));
@@ -285,11 +281,11 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
@Test
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public void tableWithLiteralZone() throws SqlParseException {
- var node = parse("CREATE TABLE t (id int) WITH
PRIMARY_ZONE='test_zone'");
+ SqlNode node = parse("CREATE TABLE t (id int) ZONE \"test_zone\"");
assertThat(node, instanceOf(SqlDdl.class));
- var cmd = converter.convert((SqlDdl) node, createContext());
+ CatalogCommand cmd = converter.convert((SqlDdl) node, createContext());
assertThat(cmd, Matchers.instanceOf(CreateTableCommand.class));
@@ -613,12 +609,12 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
@Test
public void tableWithAutogenPkColumn() throws SqlParseException {
- var node = parse("CREATE TABLE t (id uuid default rand_uuid primary
key, val int) WITH STORAGE_PROFILE='"
+ SqlNode node = parse("CREATE TABLE t (id uuid default rand_uuid
primary key, val int) STORAGE PROFILE '"
+ DEFAULT_STORAGE_PROFILE + "'");
assertThat(node, instanceOf(SqlDdl.class));
- var cmd = converter.convert((SqlDdl) node, createContext());
+ CatalogCommand cmd = converter.convert((SqlDdl) node, createContext());
assertThat(cmd, Matchers.instanceOf(CreateTableCommand.class));
@@ -631,11 +627,11 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
allOf(
hasItem(columnThat("column with name \"VAL\"", cd ->
"VAL".equals(cd.name()))),
hasItem(columnThat("PK with functional default",
- col -> "ID".equals(col.name())
- && !col.nullable()
- && ColumnType.UUID == col.type()
- && col.defaultValue().type() ==
DefaultValue.Type.FUNCTION_CALL
- &&
"RAND_UUID".equals(((DefaultValue.FunctionCall)
col.defaultValue()).functionName())
+ col -> "ID".equals(col.name())
+ && !col.nullable()
+ && ColumnType.UUID ==
col.type()
+ && col.defaultValue().type()
== DefaultValue.Type.FUNCTION_CALL
+ &&
"RAND_UUID".equals(((DefaultValue.FunctionCall)
col.defaultValue()).functionName())
)
)
)
@@ -643,28 +639,26 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
}
@Test
- public void tableWithoutStorageProfileShouldThrowError() throws
SqlParseException {
- var node = parse("CREATE TABLE t (val int) with storage_profile=''");
+ @WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
+ public void tableWithEmptyStorageProfileShouldThrowError() throws
SqlParseException {
+ SqlNode node = parse("CREATE TABLE t (val int) storage profile ''");
assertThat(node, instanceOf(SqlDdl.class));
- var ex = assertThrows(
- IgniteException.class,
+ assertThrowsSqlException(STMT_VALIDATION_ERR,
+ "String cannot be empty",
() -> converter.convert((SqlDdl) node, createContext())
);
- assertThat(ex.getMessage(), containsString("String cannot be empty"));
-
- var newNode = parse("CREATE TABLE t (val int) WITH
PRIMARY_ZONE='ZONE', storage_profile=''");
+ SqlNode newNode = parse("CREATE TABLE t (val int) ZONE ZONE storage
profile ''");
assertThat(node, instanceOf(SqlDdl.class));
- ex = assertThrows(
- IgniteException.class,
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "String cannot be empty",
() -> converter.convert((SqlDdl) newNode, createContext())
);
-
- assertThat(ex.getMessage(), containsString("String cannot be empty"));
}
// TODO: https://issues.apache.org/jira/browse/IGNITE-17373
@@ -676,7 +670,7 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
String error = format("Type {} cannot be used in a column definition
[column=P].", sqlTypeName.getSpaceName());
{
- var node = parse(format("CREATE TABLE t (id INTEGER PRIMARY KEY, p
INTERVAL {})", typeName));
+ SqlNode node = parse(format("CREATE TABLE t (id INTEGER PRIMARY
KEY, p INTERVAL {})", typeName));
assertThat(node, instanceOf(SqlDdl.class));
assertThrowsSqlException(STMT_VALIDATION_ERR, error,
@@ -684,7 +678,7 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
}
{
- var node = parse(format("CREATE TABLE t (id INTEGER PRIMARY KEY, p
INTERVAL {} NOT NULL)", typeName));
+ SqlNode node = parse(format("CREATE TABLE t (id INTEGER PRIMARY
KEY, p INTERVAL {} NOT NULL)", typeName));
assertThat(node, instanceOf(SqlDdl.class));
assertThrowsSqlException(STMT_VALIDATION_ERR, error,
@@ -701,7 +695,7 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
String error = format("Type {} cannot be used in a column definition
[column=P].", sqlTypeName.getSpaceName());
{
- var node = parse(format("ALTER TABLE t ADD COLUMN p INTERVAL {}",
typeName));
+ SqlNode node = parse(format("ALTER TABLE t ADD COLUMN p INTERVAL
{}", typeName));
assertThat(node, instanceOf(SqlDdl.class));
assertThrowsSqlException(STMT_VALIDATION_ERR, error,
@@ -709,7 +703,7 @@ public class DdlSqlToCommandConverterTest extends
AbstractDdlSqlToCommandConvert
}
{
- var node = parse(format("ALTER TABLE t ADD COLUMN p INTERVAL {}
NOT NULL", typeName));
+ SqlNode node = parse(format("ALTER TABLE t ADD COLUMN p INTERVAL
{} NOT NULL", typeName));
assertThat(node, instanceOf(SqlDdl.class));
assertThrowsSqlException(STMT_VALIDATION_ERR, error,
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/CommentParsingTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/CommentParsingTest.java
index bc19dadca3..f425ceaf06 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/CommentParsingTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/CommentParsingTest.java
@@ -226,7 +226,7 @@ public class CommentParsingTest extends AbstractParserTest {
DML_DELETE("DELETE", "FROM", "t", "WHERE", "EXISTS(" + Q15_STRING +
")"),
DDL("CREATE", "TABLE", "t", "(", "id", "INT", "PRIMARY", "KEY", ",",
"val VARCHAR", "NOT", "NULL",
- ",", "PRIMARY", "KEY (", "id", ")", ")", "WITH",
"PRIMARY_ZONE", "=", "mZone"),
+ ",", "PRIMARY", "KEY (", "id", ")", ")", "ZONE", "mZone"),
EXPLAIN("EXPLAIN", "PLAN", "FOR", Q15_STRING),
diff --git
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
index 3b1c3e3175..a11aaec96e 100644
---
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
+++
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/SqlDdlParserTest.java
@@ -30,7 +30,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.List;
-import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.calcite.schema.ColumnStrategy;
@@ -468,45 +467,19 @@ public class SqlDdlParserTest extends AbstractParserTest {
// Check uparse 'COLOCATE' and 'WITH' together.
createTable = parseCreateTable(
- "CREATE TABLE MY_TABLE(ID0 INT, ID1 INT, ID2 INT, VAL INT,
PRIMARY KEY (ID0, ID1, ID2)) COLOCATE (ID0) "
- + "with "
- + "replicas=2, "
- + "partitions=3"
+ "CREATE TABLE MY_TABLE(ID0 INT, ID1 INT, ID2 INT, VAL INT,
PRIMARY KEY (ID0, ID1, ID2)) COLOCATE (ID0)"
);
expectUnparsed(createTable, "CREATE TABLE \"MY_TABLE\" ("
+ "\"ID0\" INTEGER, \"ID1\" INTEGER, "
+ "\"ID2\" INTEGER, \"VAL\" INTEGER, PRIMARY KEY (\"ID0\",
\"ID1\", \"ID2\")"
- + ") COLOCATE BY (\"ID0\") WITH \"REPLICAS\" = 2,
\"PARTITIONS\" = 3"
- );
- }
-
- @Test
- public void createTableWithOptions() {
- String query = "create table my_table(id int) with"
- + " replicas=2,"
- + " partitions=3,"
- + " primary_zone='zone123'";
-
- SqlNode node = parse(query);
-
- assertThat(node, instanceOf(IgniteSqlCreateTable.class));
-
- IgniteSqlCreateTable createTable = (IgniteSqlCreateTable) node;
-
- assertThatOptionPresent(createTable.createOptionList().getList(),
"REPLICAS", 2);
- assertThatOptionPresent(createTable.createOptionList().getList(),
"PARTITIONS", 3);
- assertThatOptionPresent(createTable.createOptionList().getList(),
"PRIMARY_ZONE", "zone123");
-
- expectUnparsed(node, "CREATE TABLE \"MY_TABLE\" ("
- + "\"ID\" INTEGER"
- + ") WITH \"REPLICAS\" = 2, \"PARTITIONS\" = 3,
\"PRIMARY_ZONE\" = 'zone123'"
+ + ") COLOCATE BY (\"ID0\")"
);
}
@Test
public void createTableWithIdentifierZone() {
- String sqlQuery = "create table my_table(id int) with
primary_zone=zone123";
+ String sqlQuery = "create table my_table(id int) zone \"zone123\"";
SqlNode node = parse(sqlQuery);
@@ -514,24 +487,9 @@ public class SqlDdlParserTest extends AbstractParserTest {
IgniteSqlCreateTable createTable = (IgniteSqlCreateTable) node;
- assertThatOptionPresent(createTable.createOptionList().getList(),
"PRIMARY_ZONE", "ZONE123");
+ assertThat(createTable.zone().getSimple(), equalTo("zone123"));
- expectUnparsed(node, "CREATE TABLE \"MY_TABLE\" (\"ID\" INTEGER) WITH
\"PRIMARY_ZONE\" = \"ZONE123\"");
- }
-
- @Test
- public void createTableWithLiteralZone() {
- String sqlQuery = "create table my_table(id int) with
primary_zone='zone123'";
-
- SqlNode node = parse(sqlQuery);
-
- assertThat(node, instanceOf(IgniteSqlCreateTable.class));
-
- IgniteSqlCreateTable createTable = (IgniteSqlCreateTable) node;
-
- assertThatOptionPresent(createTable.createOptionList().getList(),
"PRIMARY_ZONE", "zone123");
-
- expectUnparsed(node, "CREATE TABLE \"MY_TABLE\" (\"ID\" INTEGER) WITH
\"PRIMARY_ZONE\" = 'zone123'");
+ expectUnparsed(node, "CREATE TABLE \"MY_TABLE\" (\"ID\" INTEGER) ZONE
\"zone123\"");
}
@Test
@@ -705,7 +663,7 @@ public class SqlDdlParserTest extends AbstractParserTest {
&& ((SqlBasicCall)
bc.getOperandList().get(0)).getOperandList().get(0) instanceof SqlIdentifier
&& ((SqlIdentifier) ((SqlBasicCall)
bc.getOperandList().get(0)).getOperandList().get(0)).isSimple()
&& ((SqlIdentifier) ((SqlBasicCall)
bc.getOperandList().get(0)).getOperandList().get(0))
- .getSimple().equals("COL3"))));
+ .getSimple().equals("COL3"))));
expectUnparsed(node, "CREATE INDEX \"MY_INDEX\" ON \"MY_TABLE\" ("
+ "\"COL1\" NULLS FIRST, \"COL2\" NULLS LAST, \"COL3\" DESC
NULLS FIRST)"
@@ -902,8 +860,7 @@ public class SqlDdlParserTest extends AbstractParserTest {
}
/**
- * Test makes sure exception is not thrown for CHARACTER VARYING type and
in CAST operation where CHARACTER
- * is allowed.
+ * Test makes sure exception is not thrown for CHARACTER VARYING type and
in CAST operation where CHARACTER is allowed.
*/
@ParameterizedTest
@ValueSource(strings = {
@@ -947,23 +904,4 @@ public class SqlDdlParserTest extends AbstractParserTest {
assertThat(List.of(typeName),
is(declaration.dataType.getTypeName().names));
assertThat(nullable, is(declaration.dataType.getNullable()));
}
-
- private void assertThatOptionPresent(List<SqlNode> optionList, String
option, Object expVal) {
- assertThat(optionList, hasItem(ofTypeMatching(
- option + "=" + expVal,
- IgniteSqlCreateTableOption.class,
- opt -> {
- if (opt.key().getSimple().equals(option)) {
- SqlNode valNode = opt.value();
- if (valNode instanceof SqlLiteral) {
- return Objects.equals(expVal, ((SqlLiteral)
valNode).getValueAs(expVal.getClass()));
- } else if (valNode instanceof SqlIdentifier) {
- return Objects.equals(expVal, ((SqlIdentifier)
valNode).getSimple());
- }
- }
-
- return false;
- }
- )));
- }
}
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItPartitionStoragesTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItPartitionStoragesTest.java
index d72492098e..1cf1733aab 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItPartitionStoragesTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/distributed/ItPartitionStoragesTest.java
@@ -58,7 +58,7 @@ class ItPartitionStoragesTest extends
ClusterPerTestIntegrationTest {
session
);
executeUpdate("create table " + TABLE_NAME + " (key int primary
key, val varchar(20))"
- + " with primary_zone='TEST_ZONE', storage_profile='" +
DEFAULT_STORAGE_PROFILE + "';", session);
+ + " zone TEST_ZONE storage profile '" +
DEFAULT_STORAGE_PROFILE + "';", session);
});
}
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryManagerTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryManagerTest.java
index f663cba0ec..cd4d204a6a 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryManagerTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryManagerTest.java
@@ -56,7 +56,7 @@ public class ItDisasterRecoveryManagerTest extends
ClusterPerTestIntegrationTest
));
executeSql(String.format(
- "CREATE TABLE %s (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE='%s'",
+ "CREATE TABLE %s (id INT PRIMARY KEY, val INT) ZONE %s",
TABLE_NAME,
ZONE_NAME
));
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
index b3d8424877..dea685073b 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/disaster/ItDisasterRecoveryReconfigurationTest.java
@@ -157,7 +157,7 @@ public class ItDisasterRecoveryReconfigurationTest extends
ClusterPerTestIntegra
zoneId = requireNonNull(zone).id();
waitForScale(node0, zoneParams.nodes());
- executeSql(format("CREATE TABLE %s (id INT PRIMARY KEY, val INT) WITH
PRIMARY_ZONE='%s'", TABLE_NAME, zoneName));
+ executeSql(format("CREATE TABLE %s (id INT PRIMARY KEY, val INT) ZONE
%s", TABLE_NAME, zoneName));
TableManager tableManager = unwrapTableManager(node0.tables());
tableId = ((TableViewInternal)
tableManager.table(TABLE_NAME)).tableId();
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
index 42e56854c1..71b181013f 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
@@ -307,7 +307,7 @@ class ItTableRaftSnapshotsTest extends
BaseIgniteAbstractTest {
String zoneSql = "create zone test_zone with partitions=1, replicas=3,
storage_profiles='" + storageProfile + "';";
String sql = "create table test (key int primary key, val varchar(20))"
- + " with primary_zone='TEST_ZONE', storage_profile='" +
storageProfile + "';";
+ + " zone TEST_ZONE storage profile '" + storageProfile + "';";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java
index 0205f4f557..738f1dfbbe 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceRecoveryTest.java
@@ -48,7 +48,7 @@ public class ItRebalanceRecoveryTest extends
ClusterPerTestIntegrationTest {
cluster.doInSession(0, session -> {
session.execute(null, "CREATE ZONE TEST_ZONE WITH PARTITIONS=1,
REPLICAS=1, STORAGE_PROFILES='"
+ DEFAULT_STORAGE_PROFILE + "'");
- session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) WITH PRIMARY_ZONE='TEST_ZONE'");
+ session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) ZONE TEST_ZONE");
session.execute(null, "INSERT INTO TEST VALUES (0, 0)");
});
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java
index eec769ec44..1bc54ec691 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java
@@ -214,7 +214,7 @@ public class ItRebalanceTest extends BaseIgniteAbstractTest
{
private int createTestTable(String tableName, String zoneName) {
String sql2 = "create table " + tableName + " (id int primary key, val
varchar(20))"
- + " with primary_zone='" + zoneName + "'";
+ + " zone " + zoneName;
cluster.doInSession(0, session -> {
executeUpdate(sql2, session);
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java
index 43331db080..ff4e9d9b82 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTriggersRecoveryTest.java
@@ -95,7 +95,7 @@ public class ItRebalanceTriggersRecoveryTest extends
ClusterPerTestIntegrationTe
cluster.doInSession(0, session -> {
session.execute(null, "CREATE ZONE TEST_ZONE WITH PARTITIONS=1,
REPLICAS=2, DATA_NODES_FILTER='$[?(@.region == \"US\")]', "
+ "STORAGE_PROFILES='" + DEFAULT_STORAGE_PROFILE + "'");
- session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) WITH PRIMARY_ZONE='TEST_ZONE'");
+ session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) ZONE TEST_ZONE");
session.execute(null, "INSERT INTO TEST VALUES (0, 0)");
});
@@ -141,7 +141,7 @@ public class ItRebalanceTriggersRecoveryTest extends
ClusterPerTestIntegrationTe
cluster.doInSession(0, session -> {
session.execute(null, "CREATE ZONE TEST_ZONE WITH PARTITIONS=1,
REPLICAS=1, "
+ "DATA_NODES_FILTER='$[?(@.zone == \"global\")]',
STORAGE_PROFILES='" + DEFAULT_STORAGE_PROFILE + "'");
- session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) WITH PRIMARY_ZONE='TEST_ZONE'");
+ session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) ZONE TEST_ZONE");
session.execute(null, "INSERT INTO TEST VALUES (0, 0)");
});
@@ -189,7 +189,7 @@ public class ItRebalanceTriggersRecoveryTest extends
ClusterPerTestIntegrationTe
cluster.doInSession(0, session -> {
session.execute(null, "CREATE ZONE TEST_ZONE WITH PARTITIONS=1,
REPLICAS=1, "
+ "DATA_NODES_FILTER='$[?(@.region == \"US\")]',
STORAGE_PROFILES='" + DEFAULT_STORAGE_PROFILE + "'");
- session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) WITH PRIMARY_ZONE='TEST_ZONE'");
+ session.execute(null, "CREATE TABLE TEST (id INT PRIMARY KEY, name
INT) ZONE TEST_ZONE");
session.execute(null, "INSERT INTO TEST VALUES (0, 0)");
});
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItEstimatedSizeTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItEstimatedSizeTest.java
index 670aca15a4..d37b65864e 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItEstimatedSizeTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItEstimatedSizeTest.java
@@ -140,7 +140,7 @@ public class ItEstimatedSizeTest extends
ClusterPerTestIntegrationTest {
String tableName = tableName(profile);
executeSql(String.format(
- "CREATE TABLE %s (key INT PRIMARY KEY) WITH PRIMARY_ZONE=%s,
STORAGE_PROFILE='%s'",
+ "CREATE TABLE %s (key INT PRIMARY KEY) ZONE %s STORAGE PROFILE
'%s'",
tableName,
TEST_ZONE_NAME,
profile
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItOperationRetryTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItOperationRetryTest.java
index b83c906717..b13b4f8988 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItOperationRetryTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItOperationRetryTest.java
@@ -56,7 +56,7 @@ public class ItOperationRetryTest extends
ClusterPerTestIntegrationTest {
@BeforeEach
public void setup() throws Exception {
String zoneSql = "create zone test_zone with partitions=1, replicas=3,
storage_profiles='" + DEFAULT_PROFILE_NAME + "'";
- String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) with primary_zone='TEST_ZONE'";
+ String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) zone TEST_ZONE";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionPrimaryChangeTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionPrimaryChangeTest.java
index 16e5b12581..7c3635c125 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionPrimaryChangeTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionPrimaryChangeTest.java
@@ -69,7 +69,7 @@ public class ItTransactionPrimaryChangeTest extends
ClusterPerTestIntegrationTes
@BeforeEach
public void setup() throws Exception {
String zoneSql = "create zone test_zone with partitions=1, replicas=3,
storage_profiles='" + DEFAULT_AIPERSIST_PROFILE_NAME + "'";
- String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) with primary_zone='TEST_ZONE'";
+ String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) zone TEST_ZONE";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionRecoveryTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionRecoveryTest.java
index a4b0d121cf..c4cc920336 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionRecoveryTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTransactionRecoveryTest.java
@@ -22,6 +22,7 @@ import static
org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
import static org.apache.ignite.internal.TestWrappers.unwrapTableImpl;
import static
org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
import static
org.apache.ignite.internal.sql.engine.util.SqlTestUtils.executeUpdate;
+import static
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrowsWithCode;
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.bypassingThreadAssertions;
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
import static
org.apache.ignite.internal.testframework.asserts.CompletableFutureAssert.assertWillThrow;
@@ -37,7 +38,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -87,6 +87,7 @@ import
org.apache.ignite.internal.tx.message.TxFinishReplicaRequest;
import org.apache.ignite.internal.tx.message.TxRecoveryMessage;
import org.apache.ignite.internal.tx.message.TxStateCommitPartitionRequest;
import org.apache.ignite.internal.util.ExceptionUtils;
+import org.apache.ignite.lang.ErrorGroups.Replicator;
import org.apache.ignite.lang.ErrorGroups.Transactions;
import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.table.RecordView;
@@ -118,7 +119,7 @@ public class ItTransactionRecoveryTest extends
ClusterPerTestIntegrationTest {
@BeforeEach
public void setup() throws Exception {
String zoneSql = "create zone test_zone with partitions=1, replicas=3,
storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'";
- String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) with primary_zone='TEST_ZONE'";
+ String sql = "create table " + TABLE_NAME + " (key int primary key,
val varchar(20)) zone TEST_ZONE";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
@@ -771,10 +772,14 @@ public class ItTransactionRecoveryTest extends
ClusterPerTestIntegrationTest {
return false;
});
- assertThrows(TransactionException.class, () -> {
- RecordView<Tuple> view =
txCrdNode.tables().table(TABLE_NAME).recordView();
- view.upsert(rwTx1, Tuple.create().set("key", 1).set("val",
"val1"));
- });
+ assertThrowsWithCode(
+ TransactionException.class,
+ Replicator.REPLICA_TIMEOUT_ERR,
+ () -> {
+ RecordView<Tuple> view =
txCrdNode.tables().table(TABLE_NAME).recordView();
+ view.upsert(rwTx1, Tuple.create().set("key", 1).set("val",
"val1"));
+ },
+ "Replication is timed out");
CompletableFuture<Void> commitFut = rwTx1.commitAsync();
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTxResourcesVacuumTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTxResourcesVacuumTest.java
index f0fe597d05..6fb3b1cb5d 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTxResourcesVacuumTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItTxResourcesVacuumTest.java
@@ -119,7 +119,7 @@ public class ItTxResourcesVacuumTest extends
ClusterPerTestIntegrationTest {
public void setup() throws Exception {
String zoneSql = "create zone test_zone with partitions=20, replicas="
+ REPLICAS
+ ", storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'";
- String sql = "create table " + TABLE_NAME + " (key bigint primary key,
val varchar(20)) with primary_zone='TEST_ZONE'";
+ String sql = "create table " + TABLE_NAME + " (key bigint primary key,
val varchar(20)) zone TEST_ZONE";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);
@@ -744,7 +744,7 @@ public class ItTxResourcesVacuumTest extends
ClusterPerTestIntegrationTest {
// For this test, create another zone and table with number of
replicas that is equal to number of nodes.
String zoneSql = "create zone test_zone_1 with partitions=20,
replicas=" + initialNodes()
+ ", storage_profiles='" + DEFAULT_STORAGE_PROFILE + "'";
- String sql = "create table " + tableName + " (key bigint primary key,
val varchar(20)) with primary_zone='TEST_ZONE_1'";
+ String sql = "create table " + tableName + " (key bigint primary key,
val varchar(20)) zone TEST_ZONE_1";
cluster.doInSession(0, session -> {
executeUpdate(zoneSql, session);