use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class DeleteAnalyzer method analyze.
public AnalyzedDeleteStatement analyze(Delete delete, ParamTypeHints typeHints, CoordinatorTxnCtx txnContext) {
StatementAnalysisContext stmtCtx = new StatementAnalysisContext(typeHints, Operation.DELETE, txnContext);
final RelationAnalysisContext relationCtx = stmtCtx.startRelation();
AnalyzedRelation relation = relationAnalyzer.analyze(delete.getRelation(), stmtCtx);
stmtCtx.endRelation();
MaybeAliasedStatement maybeAliasedStatement = MaybeAliasedStatement.analyze(relation);
relation = maybeAliasedStatement.nonAliasedRelation();
if (!(relation instanceof DocTableRelation)) {
throw new UnsupportedOperationException("Cannot delete from relations other than base tables");
}
DocTableRelation table = (DocTableRelation) relation;
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(nodeCtx, RowGranularity.CLUSTER, null, table);
ExpressionAnalyzer expressionAnalyzer = new ExpressionAnalyzer(txnContext, nodeCtx, typeHints, new FullQualifiedNameFieldProvider(relationCtx.sources(), relationCtx.parentSources(), txnContext.sessionContext().searchPath().currentSchema()), new SubqueryAnalyzer(relationAnalyzer, new StatementAnalysisContext(typeHints, Operation.READ, txnContext)));
Symbol query = Objects.requireNonNullElse(expressionAnalyzer.generateQuerySymbol(delete.getWhere(), new ExpressionAnalysisContext(txnContext.sessionContext())), Literal.BOOLEAN_TRUE);
query = maybeAliasedStatement.maybeMapFields(query);
Symbol normalizedQuery = normalizer.normalize(query, txnContext);
return new AnalyzedDeleteStatement(table, normalizedQuery);
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class NullEliminatorTest method assertReplacedAndNormalized.
private void assertReplacedAndNormalized(String expression, String expectedString) {
EvaluatingNormalizer normalizer = EvaluatingNormalizer.functionOnlyNormalizer(sqlExpressions.nodeCtx);
assertReplaced(expression, expectedString, s -> normalizer.normalize(s, CoordinatorTxnCtx.systemTransactionContext()));
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class ProjectorsTest method prepare.
@Before
public void prepare() throws Exception {
nodeCtx = createNodeContext();
memoryManager = new OnHeapMemoryManager(bytes -> {
});
projectorFactory = new ProjectionToProjectorVisitor(clusterService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new NoneCircuitBreakerService(), nodeCtx, THREAD_POOL, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS), new InputFactory(nodeCtx), new EvaluatingNormalizer(nodeCtx, RowGranularity.SHARD, r -> Literal.ofUnchecked(r.valueType(), r.valueType().sanitizeValue("1")), null), t -> null, t -> null, Version.CURRENT, new ShardId("dummy", UUID.randomUUID().toString(), 0), null);
}
use of io.crate.expression.eval.EvaluatingNormalizer in project crate by crate.
the class WhereClauseOptimizerTest method optimize.
private WhereClauseOptimizer.DetailedQuery optimize(String statement) {
QueriedSelectRelation queriedTable = e.analyze(statement);
DocTableRelation table = ((DocTableRelation) queriedTable.from().get(0));
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(e.nodeCtx, RowGranularity.CLUSTER, null, table);
return WhereClauseOptimizer.optimize(normalizer, queriedTable.where(), table.tableInfo(), e.getPlannerContext(clusterService.state()).transactionContext(), e.nodeCtx);
}
use of io.crate.expression.eval.EvaluatingNormalizer 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));
}
Aggregations