use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.
the class InsertMapPhysicalRel method entriesFn.
public Function<ExpressionEvalContext, List<Entry<Object, Object>>> entriesFn() {
PartitionedMapTable table = table();
ExpressionValues values = this.values;
return evalContext -> {
KvProjector projector = KvProjector.supplier(table.paths(), table.types(), (UpsertTargetDescriptor) table.getKeyJetMetadata(), (UpsertTargetDescriptor) table.getValueJetMetadata(), true).get(evalContext.getSerializationService());
return values.toValues(evalContext).map(projector::project).collect(toList());
};
}
use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.
the class RootResultConsumerSink method init.
@Override
public void init(@Nonnull Outbox outbox, @Nonnull Context context) {
rootResultConsumer = getNodeEngine(context.hazelcastInstance()).getSqlService().getInternalService().getResultRegistry().remove(context.jobId());
assert rootResultConsumer != null;
ExpressionEvalContext evalContext = ExpressionEvalContext.from(context);
Number limit = evaluate(limitExpression, evalContext);
if (limit == null) {
throw QueryException.error("LIMIT value cannot be null");
}
if (limit.longValue() < 0L) {
throw QueryException.error("LIMIT value cannot be negative: " + limit);
}
Number offset = evaluate(offsetExpression, evalContext);
if (offset == null) {
throw QueryException.error("OFFSET value cannot be null");
}
if (offset.longValue() < 0L) {
throw QueryException.error("OFFSET value cannot be negative: " + offset);
}
rootResultConsumer.init(limit.longValue(), offset.longValue());
}
use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.
the class IndexFilterValueTest method testValueComposite.
@Test
public void testValueComposite() {
ExpressionEvalContext evalContext = createExpressionEvalContext();
IndexFilterValue value = new IndexFilterValue(asList(constant(1, QueryDataType.BIGINT), constant("2", QueryDataType.VARCHAR)), asList(true, true));
assertEquals(composite(1L, "2"), value.getValue(evalContext));
value = new IndexFilterValue(asList(constant(null, QueryDataType.BIGINT), constant("2", QueryDataType.VARCHAR)), asList(true, true));
assertEquals(composite(AbstractIndex.NULL, "2"), value.getValue(evalContext));
value = new IndexFilterValue(asList(constant(null, QueryDataType.BIGINT), constant("2", QueryDataType.VARCHAR)), asList(false, true));
assertNull(value.getValue(evalContext));
value = new IndexFilterValue(asList(constant(1L, QueryDataType.BIGINT), constant(null, QueryDataType.VARCHAR)), asList(true, false));
assertNull(value.getValue(evalContext));
}
use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.
the class IndexFilterValueTest method testValueSimple.
@Test
public void testValueSimple() {
ExpressionEvalContext evalContext = createExpressionEvalContext();
IndexFilterValue value = new IndexFilterValue(singletonList(constant(1, QueryDataType.BIGINT)), singletonList(true));
assertEquals(1L, value.getValue(evalContext));
value = new IndexFilterValue(singletonList(constant(null, QueryDataType.BIGINT)), singletonList(true));
assertEquals(AbstractIndex.NULL, value.getValue(evalContext));
value = new IndexFilterValue(singletonList(constant(null, QueryDataType.BIGINT)), singletonList(false));
assertNull(value.getValue(evalContext));
}
use of com.hazelcast.sql.impl.expression.ExpressionEvalContext in project hazelcast by hazelcast.
the class IndexRangeFilterTest method testComparable.
@Test
public void testComparable() {
ExpressionEvalContext evalContext = createExpressionEvalContext();
assertEquals(1, new IndexRangeFilter(intValue(1, true), true, intValue(2, true), true).getComparable(evalContext));
assertEquals(AbstractIndex.NULL, new IndexRangeFilter(intValue(null, true), true, intValue(2, true), true).getComparable(evalContext));
assertNull(new IndexRangeFilter(intValue(null, false), true, intValue(2, true), true).getComparable(evalContext));
assertEquals(2, new IndexRangeFilter(null, true, intValue(2, true), true).getComparable(evalContext));
assertEquals(AbstractIndex.NULL, new IndexRangeFilter(null, true, intValue(null, true), true).getComparable(evalContext));
assertNull(new IndexRangeFilter(null, true, intValue(null, false), true).getComparable(evalContext));
}
Aggregations