Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions processing/src/main/java/org/apache/druid/math/expr/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ default ColumnIndexSupplier asColumnIndexSupplier(

final ColumnIndexSupplier delegateIndexSupplier = columnIndexSelector.getIndexSupplier(column);
if (delegateIndexSupplier == null) {
// if the column doesn't exist, check to see if the expression evaluates to a non-null result... if so, we might
// need to make a value matcher anyway
if (eval(InputBindings.nilBindings()).valueOrDefault() != null) {
return NoIndexesColumnIndexSupplier.getInstance();
}
return null;
}
final DictionaryEncodedValueIndex<?> delegateRawIndex = delegateIndexSupplier.as(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public abstract class BaseFilterTest extends InitializedNullHandlingTest
new ExpressionVirtualColumn("vdim3-concat", "dim3 + dim3", ColumnType.LONG, TestExprMacroTable.INSTANCE),
new ExpressionVirtualColumn("vdim2-offset", "array_offset(dim2, 1)", ColumnType.STRING, TestExprMacroTable.INSTANCE),
new ExpressionVirtualColumn("nestedArrayLong", "array(arrayLong)", ColumnType.ofArray(ColumnType.LONG_ARRAY), TestExprMacroTable.INSTANCE),
new ExpressionVirtualColumn("fake-nvl", "nvl(fake, 'hello')", ColumnType.STRING, TestExprMacroTable.INSTANCE),
new ListFilteredVirtualColumn("allow-dim0", DefaultDimensionSpec.of("dim0"), ImmutableSet.of("3", "4"), true),
new ListFilteredVirtualColumn("deny-dim0", DefaultDimensionSpec.of("dim0"), ImmutableSet.of("3", "4"), false),
new ListFilteredVirtualColumn("allow-dim2", DefaultDimensionSpec.of("dim2"), ImmutableSet.of("a"), true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public void testSingleValueVirtualStringColumnWithoutNulls()
assertFilterMatches(new EqualityFilter("vdim0", ColumnType.LONG, 1L, null), ImmutableList.of("1"));
}


@Test
public void testListFilteredVirtualColumn()
{
Expand Down Expand Up @@ -407,6 +408,20 @@ public void testSingleValueVirtualStringColumnWithNulls()
}
}


@Test
public void testSingleValueVirtualStringColumnMissingColumnCoalesce()
{
assertFilterMatches(
new EqualityFilter("fake-nvl", ColumnType.STRING, "0", null),
ImmutableList.of()
);
assertFilterMatches(
new EqualityFilter("fake-nvl", ColumnType.STRING, "hello", null),
ImmutableList.of("0", "1", "2", "3", "4", "5")
);
}

@Test
public void testMultiValueStringColumn()
{
Expand Down