WangCHX commented on code in PR #8498: URL: https://github.com/apache/pinot/pull/8498#discussion_r860756690
########## pinot-core/src/main/java/org/apache/pinot/core/plan/FilterPlanNode.java: ########## @@ -139,6 +146,46 @@ private boolean canApplyH3Index(Predicate predicate, FunctionContext function) { return columnName != null && _indexSegment.getDataSource(columnName).getH3Index() != null && findLiteral; } + /** + * H3 index can be applied for inclusion check iff: + * <ul> + * <li>Predicate is of type EQ</li> + * <li>Left-hand-side of the predicate is an ST_Within or ST_Contains function</li> + * <li>For ST_Within, the first argument is an identifier, the second argument is literal</li> + * <li>For ST_Contains function the first argument is literal, the second argument is an identifier</li> + * <li>The identifier column has H3 index</li> + * </ul> + */ + private boolean canApplyH3IndexForInclusionCheck(Predicate predicate, FunctionContext function) { + if (predicate.getType() != Predicate.Type.EQ) { + return false; + } + String functionName = function.getFunctionName(); + if (!CAN_APPLY_H3_INCLUSION_INDEX_FUNCTION_NAMES.contains(functionName)) { + return false; + } + List<ExpressionContext> arguments = function.getArguments(); + if (arguments.size() != 2) { + throw new BadQueryRequestException("Expect 2 arguments for function: " + functionName); + } + // TODO: handle nested geography/geometry conversion functions + if (functionName.equals("st_within") || functionName.equals("stwithin")) { + if (arguments.get(0).getType() == ExpressionContext.Type.IDENTIFIER + && arguments.get(1).getType() == ExpressionContext.Type.LITERAL) { + String columnName = arguments.get(0).getIdentifier(); + return columnName != null && _indexSegment.getDataSource(columnName).getH3Index() != null; Review Comment: sure. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org