use of io.crate.metadata.CoordinatorTxnCtx in project crate by crate.
the class SQLIntegrationTestCase method plan.
public PlanForNode plan(String stmt) {
String[] nodeNames = internalCluster().getNodeNames();
String nodeName = nodeNames[randomIntBetween(1, nodeNames.length) - 1];
Analyzer analyzer = internalCluster().getInstance(Analyzer.class, nodeName);
Planner planner = internalCluster().getInstance(Planner.class, nodeName);
NodeContext nodeCtx = internalCluster().getInstance(NodeContext.class, nodeName);
SessionContext sessionContext = new SessionContext(User.CRATE_USER, sqlExecutor.getCurrentSchema());
CoordinatorTxnCtx coordinatorTxnCtx = new CoordinatorTxnCtx(sessionContext);
RoutingProvider routingProvider = new RoutingProvider(Randomness.get().nextInt(), planner.getAwarenessAttributes());
PlannerContext plannerContext = new PlannerContext(planner.currentClusterState(), routingProvider, UUID.randomUUID(), coordinatorTxnCtx, nodeCtx, 0, null);
Plan plan = planner.plan(analyzer.analyze(SqlParser.createStatement(stmt), coordinatorTxnCtx.sessionContext(), ParamTypeHints.EMPTY), plannerContext);
return new PlanForNode(plan, nodeName, plannerContext);
}
use of io.crate.metadata.CoordinatorTxnCtx in project crate by crate.
the class PlannerTest method testExecutionPhaseIdSequence.
@Test
public void testExecutionPhaseIdSequence() throws Exception {
PlannerContext plannerContext = new PlannerContext(clusterService.state(), new RoutingProvider(Randomness.get().nextInt(), Collections.emptyList()), UUID.randomUUID(), new CoordinatorTxnCtx(SessionContext.systemSessionContext()), e.nodeCtx, 0, null);
assertThat(plannerContext.nextExecutionPhaseId(), is(0));
assertThat(plannerContext.nextExecutionPhaseId(), is(1));
}
use of io.crate.metadata.CoordinatorTxnCtx in project crate by crate.
the class RoutedCollectPhaseTest method testNormalizeNoop.
@Test
public void testNormalizeNoop() throws Exception {
RoutedCollectPhase collect = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Collections.emptyMap()), RowGranularity.DOC, Collections.singletonList(Literal.of(10)), Collections.emptyList(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_SAME_NODE);
EvaluatingNormalizer normalizer = EvaluatingNormalizer.functionOnlyNormalizer(nodeCtx);
RoutedCollectPhase normalizedCollect = collect.normalize(normalizer, new CoordinatorTxnCtx(SessionContext.systemSessionContext()));
assertThat(normalizedCollect, sameInstance(collect));
}
use of io.crate.metadata.CoordinatorTxnCtx 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.metadata.CoordinatorTxnCtx 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));
}
Aggregations