Vladsz83 commented on code in PR #11467: URL: https://github.com/apache/ignite/pull/11467#discussion_r1734943429
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ViewsIntegrationTest.java: ########## @@ -0,0 +1,432 @@ +/* + * 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.processors.query.calcite.integration; + +import java.util.Arrays; +import java.util.List; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; +import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.SqlConfiguration; +import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.apache.ignite.internal.util.typedef.G; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +/** */ +@RunWith(Parameterized.class) +public class ViewsIntegrationTest extends AbstractBasicIntegrationTest { + /** */ + private boolean persistenceEnabled; + + /** */ + private String[] predefinedSchemas; + + /** */ + @Parameterized.Parameter + public String engine; + + /** */ + @Parameterized.Parameters(name = "Query engine={0}") + public static Iterable<Object> params() { + return Arrays.asList(CalciteQueryEngineConfiguration.ENGINE_NAME, IndexingQueryEngineConfiguration.ENGINE_NAME); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super.getConfiguration(igniteInstanceName) + .setSqlConfiguration(new SqlConfiguration() + .setSqlSchemas(predefinedSchemas) + .setQueryEnginesConfiguration(engine.equals(CalciteQueryEngineConfiguration.ENGINE_NAME) ? + new CalciteQueryEngineConfiguration() : new IndexingQueryEngineConfiguration())) + .setDataStorageConfiguration(new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setPersistenceEnabled(persistenceEnabled))); + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + // No-op. + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** + * Creates and drops view. + */ + @Test + public void testCreateDrop() throws Exception { + initGrids(3); + initTable(3); + + sql("create or replace view my_view as select * from my_table"); + + assertViewsCount("PUBLIC", "MY_VIEW", 1); + + assertRowsCount(3, "select * from my_view"); + assertRowsCount(3, "select t.id, val_int, * from my_view t"); + + sql("drop view my_view"); + + assertViewsCount("PUBLIC", "MY_VIEW", 0); + } + + /** + * Tests views on different schemas. + */ + @Test + public void testDifferentSchemas() throws Exception { + initGrids(3); + initTable(5); + + IgniteCache<?, ?> cache1 = client.getOrCreateCache(new CacheConfiguration<>("CACHE1") + .setIndexedTypes(Integer.class, Integer.class)); + + IgniteCache<?, ?> cache2 = client.getOrCreateCache(new CacheConfiguration<>("CACHE2") + .setIndexedTypes(Integer.class, Integer.class)); + + IgniteCache<?, ?> cache3 = client.getOrCreateCache(new CacheConfiguration<>("CACHE3") + .setIndexedTypes(Integer.class, Integer.class) + .setSqlSchema("MY_SCHEMA") + ); Review Comment: linebreak -- 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]
