Search in sources :

Example 1 with SettableObjectBinding

use of org.apache.druid.math.expr.SettableObjectBinding in project druid by druid-io.

the class ExpressionPostAggregatorTest method testOutputTypeAndCompute.

@Test
public void testOutputTypeAndCompute() {
    ExpressionPostAggregator postAgg = new ExpressionPostAggregator("p0", "x + y", null, TestExprMacroTable.INSTANCE);
    RowSignature signature = RowSignature.builder().add("x", ColumnType.LONG).add("y", ColumnType.DOUBLE).build();
    SettableObjectBinding binding = new SettableObjectBinding().withBinding("x", 2L).withBinding("y", 3.0);
    Assert.assertEquals(ColumnType.DOUBLE, postAgg.getType(signature));
    Assert.assertEquals(5.0, postAgg.compute(binding.asMap()));
}
Also used : RowSignature(org.apache.druid.segment.column.RowSignature) SettableObjectBinding(org.apache.druid.math.expr.SettableObjectBinding) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

SettableObjectBinding (org.apache.druid.math.expr.SettableObjectBinding)1 RowSignature (org.apache.druid.segment.column.RowSignature)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1 Test (org.junit.Test)1