use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class RoutedCollectPhaseTest method testNormalizeDoesNotRemoveOrderBy.
@Test
public void testNormalizeDoesNotRemoveOrderBy() throws Exception {
Symbol toInt10 = CastFunctionResolver.generateCastFunction(Literal.of(10L), DataTypes.INTEGER);
RoutedCollectPhase collect = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Collections.emptyMap()), RowGranularity.DOC, Collections.singletonList(toInt10), Collections.emptyList(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_SAME_NODE);
collect.orderBy(new OrderBy(Collections.singletonList(toInt10)));
EvaluatingNormalizer normalizer = EvaluatingNormalizer.functionOnlyNormalizer(nodeCtx);
RoutedCollectPhase normalizedCollect = collect.normalize(normalizer, new CoordinatorTxnCtx(SessionContext.systemSessionContext()));
assertThat(normalizedCollect.orderBy(), notNullValue());
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class RoutedCollectPhaseTest method testNormalizePreservesNodePageSizeHint.
@Test
public void testNormalizePreservesNodePageSizeHint() throws Exception {
Symbol toInt10 = CastFunctionResolver.generateCastFunction(Literal.of(10L), DataTypes.INTEGER);
RoutedCollectPhase collect = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Collections.emptyMap()), RowGranularity.DOC, Collections.singletonList(toInt10), Collections.emptyList(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_SAME_NODE);
collect.nodePageSizeHint(10);
EvaluatingNormalizer normalizer = EvaluatingNormalizer.functionOnlyNormalizer(nodeCtx);
RoutedCollectPhase normalizedCollect = collect.normalize(normalizer, new CoordinatorTxnCtx(SessionContext.systemSessionContext()));
assertThat(normalizedCollect.nodePageSizeHint(), is(10));
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class EvaluatingNormalizerTest method testEvaluationClusterGranularity.
@Test
public void testEvaluationClusterGranularity() {
EvaluatingNormalizer visitor = new EvaluatingNormalizer(nodeCtx, RowGranularity.CLUSTER, referenceResolver, null);
Function op_or = prepareFunctionTree();
Symbol query = visitor.normalize(op_or, coordinatorTxnCtx);
assertThat(query, instanceOf(Function.class));
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class EvaluatingNormalizerTest method testEvaluation.
@Test
public void testEvaluation() {
EvaluatingNormalizer visitor = new EvaluatingNormalizer(nodeCtx, RowGranularity.NODE, referenceResolver, null);
Function op_or = prepareFunctionTree();
// the dummy reference load == 0.08 evaluates to true,
// so the whole query can be normalized to a single boolean literal
Symbol query = visitor.normalize(op_or, coordinatorTxnCtx);
assertThat(query, isLiteral(true));
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class SelectStatementAnalyzerTest method test_match_with_geo_shape_is_streamed_as_text_type_to_4_1_8_nodes.
@Test
public void test_match_with_geo_shape_is_streamed_as_text_type_to_4_1_8_nodes() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable("create table test (shape GEO_SHAPE)").build();
String stmt = "SELECT * FROM test WHERE MATCH (shape, 'POINT(1.2 1.3)')";
QueriedSelectRelation rel = executor.analyze(stmt);
Symbol where = rel.where();
assertThat(where, instanceOf(MatchPredicate.class));
DocTableInfo table = executor.resolveTableInfo("test");
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(executor.nodeCtx, RowGranularity.DOC, null, new DocTableRelation(table));
Symbol normalized = normalizer.normalize(where, CoordinatorTxnCtx.systemTransactionContext());
assertThat(normalized, isFunction("match"));
Function match = (Function) normalized;
assertThat(match.arguments().get(1).valueType(), is(DataTypes.GEO_SHAPE));
assertThat(match.info().ident().argumentTypes().get(1), is(DataTypes.GEO_SHAPE));
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(Version.V_4_1_8);
match.writeTo(out);
StreamInput in = out.bytes().streamInput();
in.setVersion(Version.V_4_1_8);
Function serializedTo41 = new Function(in);
assertThat(serializedTo41.info().ident().argumentTypes().get(1), is(DataTypes.STRING));
}
Aggregations