use of io.crate.sql.tree.StringLiteral in project crate by crate.
the class RepositoryParamValidatorTest method testHdfsDynamicConfParam.
@Test
public void testHdfsDynamicConfParam() throws Exception {
GenericProperties genericProperties = new GenericProperties();
genericProperties.add(new GenericProperty("path", new StringLiteral("/data")));
genericProperties.add(new GenericProperty("conf.foobar", new StringLiteral("bar")));
Settings settings = validator.convertAndValidate("hdfs", Optional.of(genericProperties), ParameterContext.EMPTY);
assertThat(settings.get("conf.foobar"), is("bar"));
}
use of io.crate.sql.tree.StringLiteral in project crate by crate.
the class ESClusterUpdateSettingsTaskTest method testUpdateSettingsWithStringValue.
@Test
public void testUpdateSettingsWithStringValue() throws Exception {
Map<String, List<Expression>> settings = new HashMap<String, List<Expression>>() {
{
put("cluster.graceful_stop.min_availability", ImmutableList.<Expression>of(new StringLiteral("full")));
}
};
Settings expected = Settings.builder().put("cluster.graceful_stop.min_availability", "full").build();
assertThat(ESClusterUpdateSettingsTask.buildSettingsFrom(settings, Row.EMPTY), is(expected));
}
use of io.crate.sql.tree.StringLiteral in project crate by crate.
the class TestStatementBuilder method testCaseSensitivity.
@Test
public void testCaseSensitivity() {
Expression expression = SqlParser.createExpression("\"firstName\" = 'myName'");
QualifiedNameReference nameRef = (QualifiedNameReference) ((ComparisonExpression) expression).getLeft();
StringLiteral myName = (StringLiteral) ((ComparisonExpression) expression).getRight();
assertThat(nameRef.getName().getSuffix(), is("firstName"));
assertThat(myName.getValue(), is("myName"));
expression = SqlParser.createExpression("FIRSTNAME = 'myName'");
nameRef = (QualifiedNameReference) ((ComparisonExpression) expression).getLeft();
assertThat(nameRef.getName().getSuffix(), is("firstname"));
expression = SqlParser.createExpression("ABS(1)");
QualifiedName functionName = ((FunctionCall) expression).getName();
assertThat(functionName.getSuffix(), is("abs"));
}
use of io.crate.sql.tree.StringLiteral in project crate by crate.
the class AstBuilder method visitTrim.
@Override
public Node visitTrim(SqlBaseParser.TrimContext ctx) {
Expression target = (Expression) visit(ctx.target);
if (ctx.charsToTrim == null && ctx.trimMode == null) {
return new FunctionCall(QualifiedName.of("trim"), List.of(target));
}
Expression charsToTrim = visitIfPresent(ctx.charsToTrim, Expression.class).orElse(new StringLiteral(" "));
StringLiteral trimMode = new StringLiteral(getTrimMode(ctx.trimMode).value());
return new FunctionCall(QualifiedName.of("trim"), List.of(target, charsToTrim, trimMode));
}
use of io.crate.sql.tree.StringLiteral in project crate by crate.
the class AstBuilder method visitQuotedIdentifier.
@Override
public Node visitQuotedIdentifier(SqlBaseParser.QuotedIdentifierContext context) {
String token = context.getText();
String identifier = token.substring(1, token.length() - 1).replace("\"\"", "\"");
return new StringLiteral(identifier);
}
Aggregations