Search in sources :

Example 1 with ExpressionValue

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

the class IsNullPredicateIntegrationTest method testLiteral.

@Test
public void testLiteral() {
    Class<? extends ExpressionValue> clazz = ExpressionValue.createClass(INTEGER);
    int key = 0;
    ExpressionValue value = ExpressionValue.create(clazz, 0, 1);
    put(key, value);
    checkLiteral("null", true);
    checkLiteral("true", false);
    checkLiteral("false", false);
    checkLiteral("1", false);
    checkLiteral("1.1", false);
    checkLiteral("1.1E1", false);
    checkLiteral("'a'", false);
}
Also used : ExpressionValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionValue) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ExpressionValue

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

the class SqlIndexCastTest method check.

private void check(ExpressionType<?> typeFrom, QueryDataTypeFamily typeTo, boolean expectedIndexUsage) {
    // Put value into map.
    Map map = instance().getMap(MAP_NAME);
    Class<? extends ExpressionValue> valueClass = ExpressionValue.createClass(typeFrom);
    ExpressionValue value = ExpressionValue.create(valueClass).field1(typeFrom.valueFrom());
    map.put(0, value);
    checkComparison(typeFrom, typeTo, expectedIndexUsage);
    checkIsNull(typeFrom, typeTo, expectedIndexUsage);
}
Also used : ExpressionValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionValue) Map(java.util.Map)

Example 3 with ExpressionValue

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

the class ColumnIntegrationTest method testColumn_auto.

@Test
public void testColumn_auto() {
    for (ExpressionType<?> type : ExpressionTypes.all()) {
        Class<? extends ExpressionValue> clazz = ExpressionValue.createClass(type.typeName());
        ExpressionValue value = ExpressionValue.create(clazz, type.valueFrom());
        ExpressionValue nullValue = ExpressionValue.create(clazz, null);
        SqlColumnType expectedType = type.getFieldConverterType().getTypeFamily().getPublicType();
        Object expectedResult = type.getFieldConverterType().getConverter().convertToSelf(type.getFieldConverterType().getConverter(), type.valueFrom());
        putAndCheckValue(value, sql("field1"), expectedType, expectedResult);
        putAndCheckValue(nullValue, sql("field1"), expectedType, null);
    }
}
Also used : ExpressionValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionValue) SqlColumnType(com.hazelcast.sql.SqlColumnType) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ExpressionValue

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

the class IsNullPredicateIntegrationTest method testParameter.

@Test
public void testParameter() {
    Class<? extends ExpressionValue> clazz = ExpressionValue.createClass(INTEGER);
    int key = 0;
    ExpressionValue value = ExpressionValue.create(clazz, 0, 1);
    put(key, value);
    assertEquals(set(key), keys("SELECT key FROM map WHERE ? IS NULL", new Object[] { null }));
    assertEquals(set(), keys("SELECT key FROM map WHERE ? IS NOT NULL", new Object[] { null }));
    checkParameter(key, BOOLEAN);
    checkParameter(key, BYTE);
    checkParameter(key, SHORT);
    checkParameter(key, INTEGER);
    checkParameter(key, LONG);
    checkParameter(key, BIG_INTEGER);
    checkParameter(key, BIG_DECIMAL);
    checkParameter(key, FLOAT);
    checkParameter(key, DOUBLE);
    checkParameter(key, STRING);
    checkParameter(key, CHARACTER);
    checkParameter(key, LOCAL_DATE);
    checkParameter(key, LOCAL_TIME);
    checkParameter(key, LOCAL_DATE_TIME);
    checkParameter(key, OFFSET_DATE_TIME);
    checkParameter(key, OBJECT);
}
Also used : ExpressionValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionValue) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ExpressionValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionValue)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 SqlColumnType (com.hazelcast.sql.SqlColumnType)1 Map (java.util.Map)1