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);
}
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);
}
}
}
}
}
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);
}
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);
}
}
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;
}
Aggregations