xuzifu666 commented on code in PR #4684:
URL: https://github.com/apache/calcite/pull/4684#discussion_r2617757239
##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdExpressionLineage.java:
##########
@@ -387,6 +389,30 @@ protected RelMdExpressionLineage() {}
return createAllPossibleExpressions(rexBuilder, outputExpression, mapping);
}
+ private static @Nullable Set<RexNode>
getExpressionLineageForProjectExpr(RelMetadataQuery mq,
+ RelNode input, RexNode expr) {
+ if (expr instanceof RexSubQuery) {
+ return getLineageFromSubQuery(mq, (RexSubQuery) expr);
+ }
+ if (extractInputRefs(expr).isEmpty()) {
+ return ImmutableSet.of(expr);
+ }
+ return mq.getExpressionLineage(input, expr);
+ }
+
+ private static Set<RexNode> getLineageFromSubQuery(RelMetadataQuery mq,
+ RexSubQuery subQuery) {
+ final List<RelDataTypeField> fields =
subQuery.rel.getRowType().getFieldList();
+ if (!fields.isEmpty()) {
+ final RexInputRef subRef = RexInputRef.of(0, fields);
+ final Set<RexNode> result = mq.getExpressionLineage(subQuery.rel,
subRef);
+ if (result != null) {
Review Comment:
Okay, I've looked at this logic, and it seems that NULL and empty have
equivalent effects. If that's indeed the case, then this processing is correct.
--
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]