use of io.crate.sql.tree.FunctionCall 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.FunctionCall 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.FunctionCall in project crate by crate.
the class AstBuilder method visitRight.
@Override
public Node visitRight(SqlBaseParser.RightContext context) {
Expression strOrColName = (Expression) visit(context.strOrColName);
Expression len = (Expression) visit(context.len);
return new FunctionCall(QualifiedName.of("right"), List.of(strOrColName, len));
}
Aggregations