mirror of https://github.com/apache/druid.git
skip expression virtual column indexes when mvd is used as array (#15644)
This commit is contained in:
parent
911941b4a6
commit
cafc748f7e
|
@ -34,6 +34,7 @@ import org.apache.druid.segment.column.ColumnIndexSupplier;
|
|||
import org.apache.druid.segment.column.ColumnType;
|
||||
import org.apache.druid.segment.index.semantic.DictionaryEncodedValueIndex;
|
||||
import org.apache.druid.segment.serde.NoIndexesColumnIndexSupplier;
|
||||
import org.apache.druid.segment.virtual.ExpressionSelectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
@ -213,6 +214,11 @@ public interface Expr extends Cacheable
|
|||
);
|
||||
|
||||
final ColumnCapabilities capabilities = columnIndexSelector.getColumnCapabilities(column);
|
||||
if (!ExpressionSelectors.canMapOverDictionary(details, capabilities)) {
|
||||
// for mvds, expression might need to evaluate entire row, but we don't have those handy, so fall back to
|
||||
// not using indexes
|
||||
return NoIndexesColumnIndexSupplier.getInstance();
|
||||
}
|
||||
final ExpressionType inputType = ExpressionType.fromColumnTypeStrict(capabilities);
|
||||
final ColumnType outType;
|
||||
if (outputType == null) {
|
||||
|
@ -509,8 +515,8 @@ public interface Expr extends Cacheable
|
|||
* @see Parser#applyUnappliedBindings
|
||||
* @see Parser#applyUnapplied
|
||||
* @see Parser#liftApplyLambda
|
||||
* @see org.apache.druid.segment.virtual.ExpressionSelectors#makeDimensionSelector
|
||||
* @see org.apache.druid.segment.virtual.ExpressionSelectors#makeColumnValueSelector
|
||||
* @see ExpressionSelectors#makeDimensionSelector
|
||||
* @see ExpressionSelectors#makeColumnValueSelector
|
||||
*/
|
||||
@SuppressWarnings("JavadocReference")
|
||||
class BindingAnalysis
|
||||
|
|
|
@ -147,6 +147,7 @@ public abstract class BaseFilterTest extends InitializedNullHandlingTest
|
|||
new ExpressionVirtualColumn("double-vf0-add-sub", "vf0 + (vf0 - vf0)", ColumnType.FLOAT, TestExprMacroTable.INSTANCE),
|
||||
new ExpressionVirtualColumn("double-vl0-add-sub", "vl0 + (vl0 - vl0)", ColumnType.LONG, TestExprMacroTable.INSTANCE),
|
||||
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 ListFilteredVirtualColumn("allow-dim0", DefaultDimensionSpec.of("dim0"), ImmutableSet.of("3", "4"), true),
|
||||
new ListFilteredVirtualColumn("deny-dim0", DefaultDimensionSpec.of("dim0"), ImmutableSet.of("3", "4"), false),
|
||||
|
|
|
@ -483,6 +483,16 @@ public class EqualityFilterTests
|
|||
: ImmutableList.of("0", "2", "3", "4")
|
||||
);
|
||||
}
|
||||
|
||||
// array_offset behaves same on both mvds and arrays
|
||||
assertFilterMatchesSkipVectorize(
|
||||
new EqualityFilter("vdim2-offset", ColumnType.STRING, "b", null),
|
||||
ImmutableList.of("0")
|
||||
);
|
||||
assertFilterMatchesSkipVectorize(
|
||||
NotDimFilter.of(new EqualityFilter("vdim2-offset", ColumnType.STRING, "b", null)),
|
||||
NullHandling.sqlCompatible() ? ImmutableList.of() : ImmutableList.of("1", "2", "3", "4", "5")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue