use of io.crate.sql.tree.ParameterExpression in project crate by crate.
the class ESClusterUpdateSettingsTaskTest method testUpdateMultipleSettingsWithParameters.
@Test
public void testUpdateMultipleSettingsWithParameters() throws Exception {
Map<String, List<Expression>> settings = new HashMap<String, List<Expression>>() {
{
put("stats.operations_log_size", ImmutableList.<Expression>of(new ParameterExpression(1)));
put("stats.jobs_log_size", ImmutableList.<Expression>of(new ParameterExpression(2)));
}
};
Settings expected = Settings.builder().put("stats.operations_log_size", 10).put("stats.jobs_log_size", 25).build();
assertThat(ESClusterUpdateSettingsTask.buildSettingsFrom(settings, new RowN(new Object[] { 10, 25 })), is(expected));
}
use of io.crate.sql.tree.ParameterExpression in project crate by crate.
the class DeleteAnalyzer method analyze.
public AnalyzedStatement analyze(Delete node, Analysis analysis) {
int numNested = 1;
Function<ParameterExpression, Symbol> convertParamFunction = analysis.parameterContext();
StatementAnalysisContext statementAnalysisContext = new StatementAnalysisContext(analysis.sessionContext(), convertParamFunction, Operation.DELETE, analysis.transactionContext());
RelationAnalysisContext relationAnalysisContext = statementAnalysisContext.startRelation();
AnalyzedRelation analyzedRelation = relationAnalyzer.analyze(node.getRelation(), statementAnalysisContext);
assert analyzedRelation instanceof DocTableRelation : "analyzedRelation must be DocTableRelation";
DocTableRelation docTableRelation = (DocTableRelation) analyzedRelation;
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(functions, RowGranularity.CLUSTER, ReplaceMode.MUTATE, null, docTableRelation);
DeleteAnalyzedStatement deleteAnalyzedStatement = new DeleteAnalyzedStatement(docTableRelation);
ExpressionAnalyzer expressionAnalyzer = new ExpressionAnalyzer(functions, analysis.sessionContext(), convertParamFunction, new FullQualifedNameFieldProvider(relationAnalysisContext.sources()), null);
ExpressionAnalysisContext expressionAnalysisContext = new ExpressionAnalysisContext();
WhereClauseAnalyzer whereClauseAnalyzer = new WhereClauseAnalyzer(functions, deleteAnalyzedStatement.analyzedRelation());
if (analysis.parameterContext().hasBulkParams()) {
numNested = analysis.parameterContext().numBulkParams();
}
TransactionContext transactionContext = analysis.transactionContext();
for (int i = 0; i < numNested; i++) {
analysis.parameterContext().setBulkIdx(i);
Symbol query = expressionAnalyzer.generateQuerySymbol(node.getWhere(), expressionAnalysisContext);
WhereClause whereClause = new WhereClause(normalizer.normalize(query, transactionContext));
whereClause = validate(whereClauseAnalyzer.analyze(whereClause, transactionContext));
deleteAnalyzedStatement.whereClauses.add(whereClause);
}
statementAnalysisContext.endRelation();
return deleteAnalyzedStatement;
}
use of io.crate.sql.tree.ParameterExpression in project crate by crate.
the class ESClusterUpdateSettingsTaskTest method testUpdateSettingsWithInvalidTimeValue.
@Test
public void testUpdateSettingsWithInvalidTimeValue() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Invalid value for argument 'cluster.graceful_stop.timeout'");
Map<String, List<Expression>> settings = new HashMap<String, List<Expression>>() {
{
put("cluster.graceful_stop.timeout", ImmutableList.<Expression>of(new ParameterExpression(1)));
}
};
ESClusterUpdateSettingsTask.buildSettingsFrom(settings, new RowN(new Object[] { "-1h" }));
}
Aggregations