airborne12 commented on code in PR #23105:
URL: https://github.com/apache/doris/pull/23105#discussion_r1300214099
##########
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:
> if the left expr must a slot reference from table, u should check it in
`CheckMatchExpression` rule
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: [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]