use of io.crate.expression.symbol.Function in project crate by crate.
the class SymbolFormatterTest method testFormat.
@Test
public void testFormat() throws Exception {
Function f = new Function(Signature.scalar("foo", DataTypes.STRING.getTypeSignature(), DataTypes.UNDEFINED.getTypeSignature(), DataTypes.DOUBLE.getTypeSignature()), List.of(Literal.of("bar"), Literal.of(3.4)), DataTypes.DOUBLE);
assertThat(Symbols.format("This Symbol is formatted %s", f), is("This Symbol is formatted foo('bar', 3.4)"));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class RandomFunctionTest method normalizeReference.
@Test
public void normalizeReference() {
Function function = new Function(random.signature(), Collections.emptyList(), DataTypes.DOUBLE);
Function normalized = (Function) random.normalizeSymbol(function, txnCtx, sqlExpressions.nodeCtx);
assertThat(normalized, sameInstance(function));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class RoutingBuilderTest method testAllocateRouting.
@Test
public void testAllocateRouting() {
RoutingBuilder routingBuilder = new RoutingBuilder(clusterService.state(), routingProvider);
WhereClause whereClause = new WhereClause(new Function(EqOperator.SIGNATURE, List.of(tableInfo.getReference(new ColumnIdent("id")), Literal.of(2)), EqOperator.RETURN_TYPE));
routingBuilder.newAllocations();
routingBuilder.allocateRouting(tableInfo, WhereClause.MATCH_ALL, RoutingProvider.ShardSelection.ANY, null);
routingBuilder.allocateRouting(tableInfo, whereClause, RoutingProvider.ShardSelection.ANY, null);
// 2 routing allocations with different where clause must result in 2 allocated routings
List<Routing> tableRoutings = routingBuilder.routingListByTableStack.pop().get(relationName);
assertThat(tableRoutings.size(), is(2));
// The routings are the same because the RoutingProvider enforces this - this test doesn't reflect that fact
// currently because the used routing are stubbed via the TestingTableInfo
Routing routing1 = tableRoutings.get(0);
Routing routing2 = tableRoutings.get(1);
assertThat(routing1, is(routing2));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class ExpressionAnalyzerTest method testColumnsCanBeCastedWhenOnBothSidesOfOperator.
@Test
public void testColumnsCanBeCastedWhenOnBothSidesOfOperator() {
Function symbol = (Function) executor.asSymbol("doc.t5.i < doc.t5.w");
assertThat(symbol, isFunction(LtOperator.NAME));
assertThat(symbol.arguments().get(0), isFunction(ImplicitCastFunction.NAME, List.of(DataTypes.INTEGER, DataTypes.STRING)));
assertThat(symbol.arguments().get(1).valueType(), is(DataTypes.LONG));
}
use of io.crate.expression.symbol.Function in project crate by crate.
the class ExpressionAnalyzerTest method testParameterSymbolCastsAreFlattened.
@Test
public void testParameterSymbolCastsAreFlattened() {
Function comparisonFunction = (Function) executor.asSymbol("doc.t2.i = $1");
assertThat(comparisonFunction.arguments().get(1), is(instanceOf(ParameterSymbol.class)));
assertThat(comparisonFunction.arguments().get(1).valueType(), is(DataTypes.INTEGER));
}
Aggregations