airborne12 commented on code in PR #23105: URL: https://github.com/apache/doris/pull/23105#discussion_r1300213485
########## fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java: ########## @@ -169,38 +169,61 @@ public Expr visitLessThanEqual(LessThanEqual lessThanEqual, PlanTranslatorContex NullableMode.DEPEND_ON_ARGUMENT); } + private OlapTable getOlapTableFromSlotDesc(SlotDescriptor slotDesc) { + if (slotDesc != null && slotDesc.isScanSlot()) { + TupleDescriptor slotParent = slotDesc.getParent(); + return (OlapTable) slotParent.getTable(); + } + return null; + } + + private OlapTable getOlapTableDirectly(SlotRef left) { + if (left.getTableDirect() instanceof OlapTable) { + return (OlapTable) left.getTableDirect(); + } + return null; + } + @Override public Expr visitMatch(Match match, PlanTranslatorContext context) { String invertedIndexParser = null; String invertedIndexParserMode = null; SlotRef left = (SlotRef) match.left().accept(this, context); - SlotDescriptor slotDesc = left.getDesc(); - if (slotDesc != null && slotDesc.isScanSlot()) { - TupleDescriptor slotParent = slotDesc.getParent(); - OlapTable olapTbl = (OlapTable) slotParent.getTable(); - if (olapTbl == null) { - throw new AnalysisException("slotRef in matchExpression failed to get OlapTable"); - } - List<Index> indexes = olapTbl.getIndexes(); - for (Index index : indexes) { - if (index.getIndexType() == IndexDef.IndexType.INVERTED) { - List<String> columns = index.getColumns(); - if (left.getColumnName().equals(columns.get(0))) { - invertedIndexParser = index.getInvertedIndexParser(); - invertedIndexParserMode = index.getInvertedIndexParserMode(); - break; - } + + if (left == null) { + throw new AnalysisException("Left slot reference is null"); + } + OlapTable olapTbl = Optional.ofNullable(getOlapTableFromSlotDesc(left.getDesc())) + .orElse(getOlapTableDirectly(left)); + + if (olapTbl == null) { + throw new AnalysisException("slotRef in matchExpression failed to get OlapTable"); + } Review Comment: already checked, as in the following code ` private Plan checkChildren(LogicalFilter<? extends Plan> filter) { List<Expression> expressions = filter.getExpressions(); for (Expression expr : expressions) { if (expr instanceof Match) { Match matchExpression = (Match) expr; if (!(matchExpression.left() instanceof SlotReference) || !(matchExpression.right() instanceof Literal)) { throw new AnalysisException(String.format("Only support match left operand is SlotRef," + " right operand is Literal. But meet expression %s", matchExpression)); } } } return filter; }` -- 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...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org