Skip to content

Commit

Permalink
bonus tests for funsies
Browse files Browse the repository at this point in the history
  • Loading branch information
clintropolis committed Jan 23, 2025
1 parent 47f141d commit 42dfa08
Showing 1 changed file with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.data.input.InputRow;
import org.apache.druid.data.input.impl.DimensionsSpec;
Expand All @@ -34,8 +33,11 @@
import org.apache.druid.query.filter.AndDimFilter;
import org.apache.druid.query.filter.NotDimFilter;
import org.apache.druid.query.filter.SelectorDimFilter;
import org.apache.druid.query.filter.TrueDimFilter;
import org.apache.druid.segment.CursorFactory;
import org.apache.druid.segment.IndexBuilder;
import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.RowSignature;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -57,13 +59,19 @@ public class AndFilterTest extends BaseFilterTest
)
);

private static final RowSignature ROW_SIGNATURE = RowSignature.builder()
.add("dim0", ColumnType.STRING)
.add("dim1", ColumnType.STRING)
.add("dim2", ColumnType.STRING)
.build();

private static final List<InputRow> ROWS = ImmutableList.of(
PARSER.parseBatch(ImmutableMap.of("dim0", "0", "dim1", "0")).get(0),
PARSER.parseBatch(ImmutableMap.of("dim0", "1", "dim1", "0")).get(0),
PARSER.parseBatch(ImmutableMap.of("dim0", "2", "dim1", "0")).get(0),
PARSER.parseBatch(ImmutableMap.of("dim0", "3", "dim1", "0")).get(0),
PARSER.parseBatch(ImmutableMap.of("dim0", "4", "dim1", "0")).get(0),
PARSER.parseBatch(ImmutableMap.of("dim0", "5", "dim1", "0")).get(0)
makeSchemaRow(PARSER, ROW_SIGNATURE, "0", "0", "a"),
makeSchemaRow(PARSER, ROW_SIGNATURE, "1", "0", null),
makeSchemaRow(PARSER, ROW_SIGNATURE, "2", "0", "b"),
makeSchemaRow(PARSER, ROW_SIGNATURE, "3", "0", null),
makeSchemaRow(PARSER, ROW_SIGNATURE, "4", "0", "c"),
makeSchemaRow(PARSER, ROW_SIGNATURE, "5", "0", null)
);

public AndFilterTest(
Expand Down Expand Up @@ -177,6 +185,30 @@ public void testNotAnd()
);
}

@Test
public void testNotAndWithNulls()
{
assertFilterMatches(
new AndDimFilter(
ImmutableList.of(
TrueDimFilter.instance(),
new SelectorDimFilter("dim2", "c", null)
)
),
ImmutableList.of("4")
);
assertFilterMatches(
new NotDimFilter(
new AndDimFilter(ImmutableList.of(
TrueDimFilter.instance(),
new SelectorDimFilter("dim2", "c", null)
)
)
),
ImmutableList.of("0", "2")
);
}

@Test
public void test_equals()
{
Expand Down

0 comments on commit 42dfa08

Please sign in to comment.