shauryachats commented on code in PR #18064:
URL: https://github.com/apache/pinot/pull/18064#discussion_r3042182263
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/LeafStageToPinotQuery.java:
##########
@@ -98,8 +101,77 @@ private static void handleProject(Project project,
PinotQuery pinotQuery) {
private static void handleFilter(Filter filter, PinotQuery pinotQuery) {
if (filter != null) {
RexExpression rexExpression =
RexExpressionUtils.fromRexNode(filter.getCondition());
-
pinotQuery.setFilterExpression(CalciteRexExpressionParser.toExpression(rexExpression,
- pinotQuery.getSelectList()));
+ Expression filterExpression =
CalciteRexExpressionParser.toExpression(rexExpression,
+ pinotQuery.getSelectList());
+
pinotQuery.setFilterExpression(ensureFilterIsFunctionExpression(filterExpression));
+ }
+ }
+
+ /**
+ * Ensures the filter expression is a FUNCTION type that segment pruners can
process.
+ * <p>
+ * When the V2 physical optimizer passes filters through Calcite's RelNode
tree, certain expression types
+ * (REINTERPRET on bare boolean columns, constant-folded SEARCH) produce
IDENTIFIER or LITERAL Expression
+ * objects with null functionCall. Segment pruners assume all filter
expressions are FUNCTION type and NPE
+ * on these. This method wraps bare IDENTIFIERs as EQUALS(col, true) and
drops LITERAL expressions.
+ * For AND/OR/NOT nodes, operands are recursively fixed.
+ * <p>
+ * Note: This method mutates the input expression's operand lists in-place
for AND/OR/NOT nodes.
+ * It assumes the expression tree is freshly constructed and not shared
across concurrent callers.
+ */
+ static Expression ensureFilterIsFunctionExpression(Expression expression) {
Review Comment:
Or we can actually have a follow up where we can support segment pruners
supporting a `LITERAL false` expression so that they can avoid the query being
routed to servers completely.
--
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]