mirror of https://github.com/apache/druid.git
fix bug with expression virtual column indexes on missing columns for expressions that turn null values into not null values (#15959)
This commit is contained in:
parent
b69f89d9f8
commit
6145c8dd01
|
@ -207,6 +207,11 @@ public interface Expr extends Cacheable
|
|||
|
||||
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(
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -124,6 +124,7 @@ public class EqualityFilterTests
|
|||
assertFilterMatches(new EqualityFilter("vdim0", ColumnType.LONG, 1L, null), ImmutableList.of("1"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testListFilteredVirtualColumn()
|
||||
{
|
||||
|
@ -407,6 +408,20 @@ public class EqualityFilterTests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue