use of io.crate.expression.symbol.Function in project crate by crate.
the class ExpressionAnalyzerTest method testSwapFunctionLeftSide.
@Test
public void testSwapFunctionLeftSide() throws Exception {
Function cmp = (Function) expressions.normalize(executor.asSymbol("8 + 5 > t1.x"));
// the comparison was swapped so the field is on the left side
assertThat(cmp.name(), is("op_<"));
assertThat(cmp.arguments().get(0), isReference("x"));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class ExpressionAnalyzerTest method testColumnsAreCastedToLiteralType.
@Test
public void testColumnsAreCastedToLiteralType() {
Function symbol = (Function) executor.asSymbol("doc.t2.i = 1.1");
assertThat(symbol, isSQL("(_cast(doc.t2.i, 'double precision') = 1.1)"));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class CommonQueryBuilderTest method test_eq_on_alias_uses_termquery.
@Test
public void test_eq_on_alias_uses_termquery() throws Exception {
// Testing expression: col as alias = 'foo'
AliasSymbol alias = new AliasSymbol("aliased", createReference("name", DataTypes.STRING));
var literal = Literal.of("foo");
var func = new Function(EqOperator.SIGNATURE, List.of(alias, literal), DataTypes.BOOLEAN);
Query query = queryTester.toQuery(func);
assertThat(query, instanceOf(TermQuery.class));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class SimplifyEqualsOperationOnIdenticalReferencesTest method testSimplifyRefEqRefWhenRefIsNullableWithParent.
@Test
public void testSimplifyRefEqRefWhenRefIsNullableWithParent() {
Function functionToOptimize = new Function(EqOperator.SIGNATURE, List.of(NULLABLE_REF, NULLABLE_REF), DataTypes.BOOLEAN);
Function dummyParent = new Function(NotPredicate.SIGNATURE, List.of(functionToOptimize), DataTypes.BOOLEAN);
Match<Function> match = RULE.pattern().accept(functionToOptimize, Captures.empty());
assertTrue(match.isPresent());
Symbol optimizedFunction = RULE.apply(match.value(), match.captures(), NODE_CONTEXT, dummyParent);
assertThat(optimizedFunction, is(nullValue()));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class SimplifyEqualsOperationOnIdenticalReferencesTest method testSimplifyRefEqRefWhenRefIsNullableWithNoParent.
@Test
public void testSimplifyRefEqRefWhenRefIsNullableWithNoParent() {
Function functionToOptimize = new Function(EqOperator.SIGNATURE, List.of(NULLABLE_REF, NULLABLE_REF), DataTypes.BOOLEAN);
Match<Function> match = RULE.pattern().accept(functionToOptimize, Captures.empty());
assertTrue(match.isPresent());
Symbol optimizedFunction = RULE.apply(match.value(), match.captures(), NODE_CONTEXT, null);
Symbol expected = new Function(NotPredicate.SIGNATURE, List.of(new Function(IsNullPredicate.SIGNATURE, List.of(NULLABLE_REF), DataTypes.BOOLEAN)), DataTypes.BOOLEAN);
assertThat(optimizedFunction, is(expected));
}
Aggregations