Search in sources :

Example 1 with ExpressionBiValue

use of com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue in project hazelcast by hazelcast.

the class BetweenOperatorIntegrationTest method betweenSymmetricPredicateTypeCheckTest.

@Test
public void betweenSymmetricPredicateTypeCheckTest() {
    int cycleCounter = 0;
    for (ExpressionType<?> fieldType : TESTED_TYPES) {
        putAll(fieldType.nonNullValues().toArray());
        for (ExpressionType<?> lowerBoundType : TESTED_TYPES) {
            for (ExpressionType<?> upperBoundType : TESTED_TYPES) {
                ++cycleCounter;
                ExpressionBiValue biValue = ExpressionBiValue.createBiValue(lowerBoundType.valueFrom(), upperBoundType.valueTo());
                Tuple2<List<SqlRow>, HazelcastSqlException> comparisonEquivalentResult = executePossiblyFailingQuery(// the queries have extra spaces so that the errors are on the same positions
                "SELECT this FROM map WHERE (this >=     ? AND this <= ?) OR (this >= ? AND this <= ?) ORDER BY this", fieldType.getFieldConverterType().getTypeFamily().getPublicType(), biValue.field1(), biValue.field2(), biValue.field2(), biValue.field1());
                try {
                    checkSuccessOrFailure("SELECT this FROM map WHERE this BETWEEN SYMMETRIC ? AND         ?  ORDER BY this", comparisonEquivalentResult, biValue.field1(), biValue.field2());
                } catch (Throwable e) {
                    throw new AssertionError("For [" + fieldType + ", " + lowerBoundType + ", " + upperBoundType + "]: " + e, e);
                }
            }
        }
    }
    assertEquals(TESTED_TYPES.length * TESTED_TYPES.length * TESTED_TYPES.length, cycleCounter);
}
Also used : ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue) ArrayList(java.util.ArrayList) List(java.util.List) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ExpressionBiValue

use of com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue in project hazelcast by hazelcast.

the class BetweenOperatorIntegrationTest method betweenAsymmetricPredicateTypeCheckTest.

@Test
public void betweenAsymmetricPredicateTypeCheckTest() {
    for (ExpressionType<?> fieldType : TESTED_TYPES) {
        putAll(fieldType.nonNullValues().toArray());
        for (ExpressionType<?> lowerBoundType : TESTED_TYPES) {
            for (ExpressionType<?> upperBoundType : TESTED_TYPES) {
                ExpressionBiValue biValue = ExpressionBiValue.createBiValue(lowerBoundType.valueFrom(), upperBoundType.valueTo());
                Tuple2<List<SqlRow>, HazelcastSqlException> comparisonEquivalentResult = executePossiblyFailingQuery(// the queries have extra spaces so that the errors are on the same positions
                "SELECT this FROM map WHERE this >=      ? AND this <= ?  ORDER BY this", fieldType.getFieldConverterType().getTypeFamily().getPublicType(), biValue.field1(), biValue.field2());
                try {
                    checkSuccessOrFailure("SELECT this FROM map WHERE this BETWEEN ? AND         ?  ORDER BY this", comparisonEquivalentResult, biValue.field1(), biValue.field2());
                } catch (Throwable e) {
                    throw new AssertionError("For [" + fieldType + ", " + lowerBoundType + ", " + upperBoundType + "]: " + e, e);
                }
            }
        }
    }
}
Also used : ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue) ArrayList(java.util.ArrayList) List(java.util.List) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with ExpressionBiValue

use of com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue in project hazelcast by hazelcast.

the class ComparisonPredicateIntegrationTest method putBiValue.

private void putBiValue(Object field1, Object field2, ExpressionType<?> type1, ExpressionType<?> type2) {
    ExpressionBiValue value = ExpressionBiValue.createBiValue(ExpressionBiValue.createBiClass(type1, type2), field1, field2);
    put(value);
}
Also used : ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)

Example 4 with ExpressionBiValue

use of com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue in project hazelcast by hazelcast.

the class ComparisonPredicateIntegrationTest method checkUnsupportedColumnColumn.

private void checkUnsupportedColumnColumn(ExpressionType<?> type, ExpressionType<?>... excludeTypes) {
    for (ExpressionType<?> expressionType : excludeTypes) {
        ExpressionBiValue value = ExpressionBiValue.createBiValue(ExpressionBiValue.createBiClass(type, expressionType), null, null);
        put(value);
        String sql = sql(mode.token(), "field1", "field2");
        String errorMessage = signatureErrorOperator(mode.token(), type.getFieldConverterType().getTypeFamily().getPublicType(), expressionType.getFieldConverterType().getTypeFamily().getPublicType());
        checkFailure0(sql, SqlErrorCode.PARSING, errorMessage);
    }
}
Also used : ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)

Example 5 with ExpressionBiValue

use of com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue in project hazelcast by hazelcast.

the class SqlIndexAbstractTest method expectedMapKeys.

private Set<Integer> expectedMapKeys(Predicate<ExpressionValue> predicate) {
    Set<Integer> keys = new HashSet<>();
    for (Map.Entry<Integer, ExpressionBiValue> entry : localMap.entrySet()) {
        Integer key = entry.getKey();
        ExpressionBiValue value = entry.getValue();
        if (predicate.test(value)) {
            keys.add(key);
        }
    }
    return keys;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue) Map(java.util.Map) HashMap(java.util.HashMap) IMap(com.hazelcast.map.IMap) HashSet(java.util.HashSet)

Aggregations

ExpressionBiValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)8 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Test (org.junit.Test)4 IMap (com.hazelcast.map.IMap)3 HazelcastSqlException (com.hazelcast.sql.HazelcastSqlException)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 IndexConfig (com.hazelcast.config.IndexConfig)2 IndexType (com.hazelcast.config.IndexType)2 MapConfig (com.hazelcast.config.MapConfig)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 OptimizerTestSupport (com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport)1 FullScanLogicalRel (com.hazelcast.jet.sql.impl.opt.logical.FullScanLogicalRel)1 FullScanPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel)1