Index: modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IndexSetArgsAndCastTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IndexSetArgsAndCastTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IndexSetArgsAndCastTest.java new file mode 100644 --- /dev/null (date 1653395745588) +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IndexSetArgsAndCastTest.java (date 1653395745588) @@ -0,0 +1,95 @@ +/* + * 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.cache.index; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Assert; +import org.junit.Test; + + +/** + * + */ +public class IndexSetArgsAndCastTest extends AbstractIndexingCommonTest { + private static final int ROW_COUNT = 100; + + @Override + protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + cfg.setCacheConfiguration(defaultCacheConfiguration()); + return cfg; + } + + @Test + public void indexOnAutocastOff() throws Exception { + indexAutocast(true, false); + } + + @Test + public void indexOnAutocastOn() throws Exception { + indexAutocast(true, true); + } + + @Test + public void indexOffAutocastOff() throws Exception { + indexAutocast(false, false); + } + + @Test + public void indexOffAutocastOn() throws Exception { + indexAutocast(false, true); + } + + public void indexAutocast(boolean indexed, boolean autocasted) throws Exception { + try { + Ignite ignite = startGrid(0); + IgniteCache igniteCache = ignite.cache(DEFAULT_CACHE_NAME); + + igniteCache.query(new SqlFieldsQuery("create table table_test (ID NUMBER, TEST_COLUMN VARCHAR, PRIMARY KEY (ID)) " + + "WITH \"CACHE_NAME=table_test\"")) + .getAll(); + + if (indexed) + igniteCache.query(new SqlFieldsQuery("create index index_test on table_test (TEST_COLUMN)")) + .getAll(); + //fill data + for (int x = 0; x < ROW_COUNT; x++) { + igniteCache.query(new SqlFieldsQuery("insert into table_test values (?,?)") + .setArgs(x, x)) + .getAll(); + } + final int sizeAfterLoad = ignite.cache("table_test").size(); + + //delete all data + for (int x = 0; x < ROW_COUNT; x++) { + igniteCache.query(new SqlFieldsQuery("delete from table_test where TEST_COLUMN =?") + .setArgs(autocasted ? String.valueOf(x) : x)) + .getAll(); + } + final int sizeAfterDeleteAll = ignite.cache("table_test").size(); + + Assert.assertEquals(ROW_COUNT, sizeAfterLoad); + Assert.assertEquals(0, sizeAfterDeleteAll); + } finally { + stopAllGrids(); + } + } +}