Search in sources :

Example 1 with IsPredicate

use of org.apache.drill.exec.expr.IsPredicate in project drill by apache.

the class TestParquetFilterPushDown method testMinFalseMaxTrue.

// testing min=false, max=true, min/max set, no nulls
@Test
@SuppressWarnings("unchecked")
public void testMinFalseMaxTrue() {
    LogicalExpression le = Mockito.mock(LogicalExpression.class);
    ColumnStatistics<Boolean> booleanStatistics = Mockito.mock(ColumnStatistics.class);
    Mockito.doReturn(booleanStatistics).when(le).accept(ArgumentMatchers.any(), ArgumentMatchers.any());
    StatisticsProvider<Boolean> re = Mockito.mock(StatisticsProvider.class);
    // 2 rows
    Mockito.when(re.getRowCount()).thenReturn(2L);
    // stat is not empty
    Mockito.when(booleanStatistics.contains(ArgumentMatchers.any())).thenReturn(true);
    // no nulls
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.NULLS_COUNT)).thenReturn(0L);
    // min false
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.MIN_VALUE)).thenReturn(false);
    // max true
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.MAX_VALUE)).thenReturn(true);
    // comparator
    Mockito.when(booleanStatistics.getValueComparator()).thenReturn(Comparator.nullsFirst(Comparator.naturalOrder()));
    IsPredicate<Boolean> isTrue = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_TRUE, le);
    assertEquals(RowsMatch.SOME, isTrue.matches(re));
    IsPredicate<Boolean> isFalse = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_FALSE, le);
    assertEquals(RowsMatch.SOME, isFalse.matches(re));
    IsPredicate<Boolean> isNotTrue = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_NOT_TRUE, le);
    assertEquals(RowsMatch.SOME, isNotTrue.matches(re));
    IsPredicate<Boolean> isNotFalse = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_NOT_FALSE, le);
    assertEquals(RowsMatch.SOME, isNotFalse.matches(re));
}
Also used : IsPredicate(org.apache.drill.exec.expr.IsPredicate) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) Test(org.junit.Test)

Example 2 with IsPredicate

use of org.apache.drill.exec.expr.IsPredicate in project drill by apache.

the class TestParquetFilterPushDown method testMinFalseMaxFalse.

// testing min=false, max=false, min/max set, no nulls
@Test
@SuppressWarnings("unchecked")
public void testMinFalseMaxFalse() {
    LogicalExpression le = Mockito.mock(LogicalExpression.class);
    ColumnStatistics<Boolean> booleanStatistics = Mockito.mock(ColumnStatistics.class);
    Mockito.doReturn(booleanStatistics).when(le).accept(ArgumentMatchers.any(), ArgumentMatchers.any());
    StatisticsProvider<Boolean> re = Mockito.mock(StatisticsProvider.class);
    // 2 rows
    Mockito.when(re.getRowCount()).thenReturn(2L);
    // stat is not empty
    Mockito.when(booleanStatistics.contains(ArgumentMatchers.any())).thenReturn(true);
    // no nulls
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.NULLS_COUNT)).thenReturn(0L);
    // min false
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.MIN_VALUE)).thenReturn(false);
    // max false
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.MAX_VALUE)).thenReturn(false);
    // comparator
    Mockito.when(booleanStatistics.getValueComparator()).thenReturn(Comparator.nullsFirst(Comparator.naturalOrder()));
    IsPredicate<Boolean> isTrue = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_TRUE, le);
    assertEquals(RowsMatch.NONE, isTrue.matches(re));
    IsPredicate<Boolean> isFalse = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_FALSE, le);
    assertEquals(RowsMatch.ALL, isFalse.matches(re));
    IsPredicate<Boolean> isNotTrue = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_NOT_TRUE, le);
    assertEquals(RowsMatch.ALL, isNotTrue.matches(re));
    IsPredicate<Boolean> isNotFalse = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_NOT_FALSE, le);
    assertEquals(RowsMatch.NONE, isNotFalse.matches(re));
}
Also used : IsPredicate(org.apache.drill.exec.expr.IsPredicate) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) Test(org.junit.Test)

Example 3 with IsPredicate

use of org.apache.drill.exec.expr.IsPredicate in project drill by apache.

the class TestParquetFilterPushDown method testMinTrueMaxTrue.

// testing min=true, max=true, min/max set, no nulls
@Test
@SuppressWarnings("unchecked")
public void testMinTrueMaxTrue() {
    LogicalExpression le = Mockito.mock(LogicalExpression.class);
    ColumnStatistics<Boolean> booleanStatistics = Mockito.mock(ColumnStatistics.class);
    Mockito.doReturn(booleanStatistics).when(le).accept(ArgumentMatchers.any(), ArgumentMatchers.any());
    StatisticsProvider<Boolean> re = Mockito.mock(StatisticsProvider.class);
    // 2 rows
    Mockito.when(re.getRowCount()).thenReturn(Long.valueOf(2));
    // stat is not empty
    Mockito.when(booleanStatistics.contains(ArgumentMatchers.any())).thenReturn(true);
    // no nulls
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.NULLS_COUNT)).thenReturn(0L);
    // min false
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.MIN_VALUE)).thenReturn(true);
    // max false
    Mockito.when(booleanStatistics.get(ColumnStatisticsKind.MAX_VALUE)).thenReturn(true);
    IsPredicate<Boolean> isTrue = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_TRUE, le);
    assertEquals(RowsMatch.ALL, isTrue.matches(re));
    IsPredicate<Boolean> isFalse = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_FALSE, le);
    assertEquals(RowsMatch.NONE, isFalse.matches(re));
    IsPredicate<Boolean> isNotTrue = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_NOT_TRUE, le);
    assertEquals(RowsMatch.NONE, isNotTrue.matches(re));
    IsPredicate<Boolean> isNotFalse = (IsPredicate<Boolean>) IsPredicate.createIsPredicate(FunctionGenerationHelper.IS_NOT_FALSE, le);
    assertEquals(RowsMatch.ALL, isNotFalse.matches(re));
}
Also used : IsPredicate(org.apache.drill.exec.expr.IsPredicate) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) Test(org.junit.Test)

Aggregations

LogicalExpression (org.apache.drill.common.expression.LogicalExpression)3 IsPredicate (org.apache.drill.exec.expr.IsPredicate)3 Test (org.junit.Test)3