gianm commented on code in PR #15585:
URL: https://github.com/apache/druid/pull/15585#discussion_r1440046113
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java:
##########
@@ -4260,24 +4261,41 @@ public void testCountStarOnCommonTableExpression()
// cannot vectorize due to substring expression
cannotVectorize();
}
+ final TimeseriesQuery query;
+ if (NullHandling.sqlCompatible()) {
+ query = Druids.newTimeseriesQueryBuilder()
+ .dataSource(CalciteTests.DATASOURCE1)
+ .intervals(querySegmentSpec(Filtration.eternity()))
+ .virtualColumns(expressionVirtualColumn("v0",
"substring(\"dim1\", 0, 1)", ColumnType.STRING))
Review Comment:
Could probably do a `NullHandling.sqlCompatible() ?
expressionVirtualColumn(...) : new VirtualColumn[0]` to keep this as a single
call to the query builder. Or, split the builder calls up so it's not
fluent-style. Something like that might help readability. As it is, it takes
some studying to tell the difference between the two branches.
##########
processing/src/main/java/org/apache/druid/math/expr/ExprPredicateIndexSupplier.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.math.expr;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import org.apache.druid.collections.bitmap.ImmutableBitmap;
+import org.apache.druid.java.util.common.NonnullPair;
+import org.apache.druid.query.filter.DruidDoublePredicate;
+import org.apache.druid.query.filter.DruidFloatPredicate;
+import org.apache.druid.query.filter.DruidLongPredicate;
+import org.apache.druid.query.filter.DruidPredicateFactory;
+import org.apache.druid.segment.column.ColumnIndexSupplier;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.index.BitmapColumnIndex;
+import org.apache.druid.segment.index.SimpleImmutableBitmapIterableIndex;
+import org.apache.druid.segment.index.semantic.DictionaryEncodedValueIndex;
+import org.apache.druid.segment.index.semantic.DruidPredicateIndexes;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExprPredicateIndexSupplier implements ColumnIndexSupplier
+{
+ private final Expr expr;
+ private final String inputColumn;
+ private final ExpressionType inputType;
+ private final ColumnType outputType;
+ private final DictionaryEncodedValueIndex<?> inputColumnIndexes;
+
+ public ExprPredicateIndexSupplier(
+ Expr expr,
+ String inputColumn,
+ ExpressionType inputType,
+ ColumnType outputType,
+ DictionaryEncodedValueIndex<?> inputColumnValueIndexes
+ )
+ {
+ this.expr = expr;
+ this.inputColumn = inputColumn;
+ this.inputType = inputType;
+ this.outputType = outputType;
+ this.inputColumnIndexes = inputColumnValueIndexes;
+ }
+
+ @Nullable
+ @Override
+ public <T> T as(Class<T> clazz)
+ {
+ if (clazz.equals(DruidPredicateIndexes.class)) {
+ return (T) new ExprPredicateIndexes();
+ }
+ return null;
+ }
+
+ private final class ExprPredicateIndexes implements DruidPredicateIndexes
+ {
+ @Nullable
+ @Override
+ public BitmapColumnIndex forPredicate(DruidPredicateFactory matcherFactory)
+ {
+ final Supplier<NonnullPair<List<ImmutableBitmap>,
List<ImmutableBitmap>>> bitmapsSupplier;
Review Comment:
what do the two lists of bitmaps represent?
a `private static class` or some comments would help readability here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]