alex-plekhanov commented on code in PR #12453:
URL: https://github.com/apache/ignite/pull/12453#discussion_r2483159451


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java:
##########
@@ -392,15 +393,84 @@ public void createTableCustomSchema() {
      */
     @Test
     public void createTableOnExistingCache() {
-        IgniteCache<Object, Object> cache = 
client.getOrCreateCache("my_cache");
+        // Cache without SQL configuration.
+        IgniteCache<Object, Object> cache = 
client.getOrCreateCache("my_cache0");
 
-        sql("create table my_schema.my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache\"");
+        // DDL with explicit schema.
+        sql("create table my_schema.my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache0\"");
 
-        sql("insert into my_schema.my_table(f1, f2) values (1, '1'),(2, '2')");
+        checkSize(cache, "my_schema");
+
+        // Cache without SQL configuration.
+        cache = client.getOrCreateCache("my_cache1");
+
+        // DDL with implicit PUBLIC schema.
+        sql("create table my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache1\"");
+
+        checkSize(cache, "public");
+
+        // Cache with defined schema.
+        cache = client.getOrCreateCache(new 
CacheConfiguration<>("my_cache2").setSqlSchema("my_schema2"));
+
+        // DDL with explicit correct schema.
+        sql("create table my_schema2.my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache2\"");
+
+        checkSize(cache, "my_schema2");
+
+        // Cache with defined schema.
+        cache = client.getOrCreateCache(new 
CacheConfiguration<>("my_cache3").setSqlSchema("my_schema3"));
+
+        // DDL with explicit wrong schema.
+        assertThrows("create table my_schema.my_table2 (f1 int, f2 varchar) 
with cache_name=\"my_cache3\"",
+            IgniteSQLException.class, "Invalid schema: MY_SCHEMA");
+
+        // DDL with explicit wrong schema.
+        assertThrows("create table public.my_table2 (f1 int, f2 varchar) with 
cache_name=\"my_cache3\"",
+            IgniteSQLException.class, "Invalid schema: PUBLIC");
+
+        // DDL with implicit wrong schema.
+        assertThrows("create table my_table2 (f1 int, f2 varchar) with 
cache_name=\"my_cache3\"",
+            IgniteSQLException.class, "Invalid schema: PUBLIC");
+
+        // DDL woth implicit cache schema.

Review Comment:
   Fixed



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/TableDdlIntegrationTest.java:
##########
@@ -392,15 +393,84 @@ public void createTableCustomSchema() {
      */
     @Test
     public void createTableOnExistingCache() {
-        IgniteCache<Object, Object> cache = 
client.getOrCreateCache("my_cache");
+        // Cache without SQL configuration.
+        IgniteCache<Object, Object> cache = 
client.getOrCreateCache("my_cache0");
 
-        sql("create table my_schema.my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache\"");
+        // DDL with explicit schema.
+        sql("create table my_schema.my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache0\"");
 
-        sql("insert into my_schema.my_table(f1, f2) values (1, '1'),(2, '2')");
+        checkSize(cache, "my_schema");
+
+        // Cache without SQL configuration.
+        cache = client.getOrCreateCache("my_cache1");
+
+        // DDL with implicit PUBLIC schema.
+        sql("create table my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache1\"");
+
+        checkSize(cache, "public");
+
+        // Cache with defined schema.
+        cache = client.getOrCreateCache(new 
CacheConfiguration<>("my_cache2").setSqlSchema("my_schema2"));
+
+        // DDL with explicit correct schema.
+        sql("create table my_schema2.my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache2\"");
+
+        checkSize(cache, "my_schema2");
+
+        // Cache with defined schema.
+        cache = client.getOrCreateCache(new 
CacheConfiguration<>("my_cache3").setSqlSchema("my_schema3"));
+
+        // DDL with explicit wrong schema.
+        assertThrows("create table my_schema.my_table2 (f1 int, f2 varchar) 
with cache_name=\"my_cache3\"",
+            IgniteSQLException.class, "Invalid schema: MY_SCHEMA");
+
+        // DDL with explicit wrong schema.
+        assertThrows("create table public.my_table2 (f1 int, f2 varchar) with 
cache_name=\"my_cache3\"",
+            IgniteSQLException.class, "Invalid schema: PUBLIC");
+
+        // DDL with implicit wrong schema.
+        assertThrows("create table my_table2 (f1 int, f2 varchar) with 
cache_name=\"my_cache3\"",
+            IgniteSQLException.class, "Invalid schema: PUBLIC");
+
+        // DDL woth implicit cache schema.
+        cache.query(new SqlFieldsQuery("create table my_table (f1 int, f2 
varchar) with cache_name=\"my_cache3\""));
+
+        checkSize(cache, "my_schema3");
+
+        // Cache with defined SQL functions, schema is defined by cache name.
+        cache = client.getOrCreateCache(new 
CacheConfiguration<>("my_cache4").setSqlFunctionClasses(getClass()));
+
+        // DDL with explicit wrong schema.
+        assertThrows("create table public.my_table2 (f1 int, f2 varchar) with 
cache_name=\"my_cache4\"",
+            IgniteSQLException.class, "Invalid schema: PUBLIC");
+
+        // DDL with explicit correct schema.
+        sql("create table \"my_cache4\".my_table (f1 int, f2 varchar) with 
cache_name=\"my_cache4\"");
+
+        checkSize(cache, "\"my_cache4\"");
+
+        // Cache with defined query entities.
+        client.getOrCreateCache(new CacheConfiguration<>("my_cache5")
+            .setQueryEntities(Collections.singleton(new 
QueryEntity(Integer.class, Integer.class))));
+
+        assertThrows("create table \"my_cache5\".my_table (f1 int, f2 varchar) 
with cache_name=\"my_cache5\"",
+            IgniteSQLException.class, "Cache is already indexed");
+
+        // Cache with indexed types.
+        client.getOrCreateCache(new CacheConfiguration<>("my_cache6")
+            .setIndexedTypes(Integer.class, Integer.class));
+
+        assertThrows("create table \"my_cache6\".my_table (f1 int, f2 varchar) 
with cache_name=\"my_cache6\"",
+            IgniteSQLException.class, "Cache is already indexed");
+    }
+
+    /** */
+    private void checkSize(IgniteCache<?, ?> cache, String schema) {

Review Comment:
   Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to