Search in sources :

Example 1 with MapIndexScanExecIterator

use of com.hazelcast.sql.impl.exec.scan.index.MapIndexScanExecIterator in project hazelcast by hazelcast.

the class SqlIndexConverterMismatchTest method testMismatch.

/**
 * @see MapIndexScanExecIterator#getIndexEntries
 */
@SuppressWarnings({ "StatementWithEmptyBody", "JavadocReference" })
@Ignore("https://github.com/hazelcast/hazelcast/issues/19287")
@Test
public void testMismatch() {
    ExpressionBiValue value1 = new ExpressionBiValue.IntegerIntegerVal();
    value1.field1(10);
    value1.field2(10);
    ExpressionBiValue value2 = new ExpressionBiValue.StringIntegerVal();
    value2.field1("10");
    value2.field2(10);
    map.put(getLocalKey(member1, key -> key), value1);
    map.put(getLocalKey(member2, key -> key), value2);
    try {
        try (SqlResult result = member1.getSql().execute("SELECT key FROM " + MAP_NAME + " WHERE field1=1")) {
            for (SqlRow ignore : result) {
            // No-op.
            }
        }
        fail("Must fail!");
    } catch (HazelcastSqlException e) {
        assertEquals(SqlErrorCode.INDEX_INVALID, e.getCode());
        Throwable ex = findRootQueryException(e);
        assertEquals("Cannot use the index \"index\" of the IMap \"map\" because it has component \"field1\" of type VARCHAR, but INTEGER was expected", ex.getMessage());
    }
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue) ArrayList(java.util.ArrayList) MapConfig(com.hazelcast.config.MapConfig) IndexType(com.hazelcast.config.IndexType) MapIndexScanExecIterator(com.hazelcast.sql.impl.exec.scan.index.MapIndexScanExecIterator) After(org.junit.After) Assert.fail(org.junit.Assert.fail) SqlRow(com.hazelcast.sql.SqlRow) Parameterized(org.junit.runners.Parameterized) QueryException(com.hazelcast.sql.impl.QueryException) Before(org.junit.Before) UseParametersRunnerFactory(org.junit.runners.Parameterized.UseParametersRunnerFactory) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) HazelcastParametrizedRunner(com.hazelcast.test.HazelcastParametrizedRunner) Collection(java.util.Collection) HazelcastParallelParametersRunnerFactory(com.hazelcast.test.HazelcastParallelParametersRunnerFactory) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) IndexConfig(com.hazelcast.config.IndexConfig) List(java.util.List) Ignore(org.junit.Ignore) SqlResult(com.hazelcast.sql.SqlResult) SqlErrorCode(com.hazelcast.sql.impl.SqlErrorCode) Assert.assertEquals(org.junit.Assert.assertEquals) IMap(com.hazelcast.map.IMap) SqlRow(com.hazelcast.sql.SqlRow) SqlResult(com.hazelcast.sql.SqlResult) ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) Ignore(org.junit.Ignore) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Config (com.hazelcast.config.Config)1 IndexConfig (com.hazelcast.config.IndexConfig)1 IndexType (com.hazelcast.config.IndexType)1 MapConfig (com.hazelcast.config.MapConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ExpressionBiValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)1 IMap (com.hazelcast.map.IMap)1 HazelcastSqlException (com.hazelcast.sql.HazelcastSqlException)1 SqlResult (com.hazelcast.sql.SqlResult)1 SqlRow (com.hazelcast.sql.SqlRow)1 QueryException (com.hazelcast.sql.impl.QueryException)1 SqlErrorCode (com.hazelcast.sql.impl.SqlErrorCode)1 MapIndexScanExecIterator (com.hazelcast.sql.impl.exec.scan.index.MapIndexScanExecIterator)1 HazelcastParallelParametersRunnerFactory (com.hazelcast.test.HazelcastParallelParametersRunnerFactory)1 HazelcastParametrizedRunner (com.hazelcast.test.HazelcastParametrizedRunner)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1