use of org.apache.drill.common.expression.BooleanOperator in project drill by apache.
the class DruidFilterBuilderTest method visitBooleanOperatorWithAndOperator.
@Test
public void visitBooleanOperatorWithAndOperator() {
LogicalExpression logicalExpression2 = mock(LogicalExpression.class);
try {
when(logicalExpression.accept(any(), any())).thenReturn(druidScanSpecLeft);
when(logicalExpression2.accept(any(), any())).thenReturn(druidScanSpecRight);
} catch (Exception ignored) {
}
BooleanOperator booleanOperator = new BooleanOperator(FunctionNames.AND, Stream.of(logicalExpression, logicalExpression2).collect(Collectors.toList()), null);
DruidScanSpec druidScanSpec = druidFilterBuilder.visitBooleanOperator(booleanOperator, null);
String expectedFilterJson = "{\"type\":\"and\",\"fields\":[{\"type\":\"selector\",\"dimension\":\"some dimension\",\"value\":\"some value\"},{\"type\":\"selector\",\"dimension\":\"some other dimension\",\"value\":\"some other value\"}]}";
String actual = druidScanSpec.getFilter().toJson();
assertThat(actual).isEqualTo(expectedFilterJson);
}
use of org.apache.drill.common.expression.BooleanOperator in project drill by apache.
the class DruidFilterBuilderTest method visitBooleanOperatorWithOrOperator.
@Test
public void visitBooleanOperatorWithOrOperator() {
LogicalExpression logicalExpression2 = mock(LogicalExpression.class);
try {
when(logicalExpression.accept(any(), any())).thenReturn(druidScanSpecLeft);
when(logicalExpression2.accept(any(), any())).thenReturn(druidScanSpecRight);
} catch (Exception ignored) {
}
BooleanOperator booleanOperator = new BooleanOperator(FunctionNames.OR, Stream.of(logicalExpression, logicalExpression2).collect(Collectors.toList()), null);
DruidScanSpec druidScanSpec = druidFilterBuilder.visitBooleanOperator(booleanOperator, null);
String expectedFilterJson = "{\"type\":\"or\",\"fields\":[{\"type\":\"selector\",\"dimension\":\"some dimension\",\"value\":\"some value\"},{\"type\":\"selector\",\"dimension\":\"some other dimension\",\"value\":\"some other value\"}]}";
String actual = druidScanSpec.getFilter().toJson();
assertThat(actual).isEqualTo(expectedFilterJson);
}
Aggregations