jeyhunkarimov commented on code in PR #24239: URL: https://github.com/apache/flink/pull/24239#discussion_r1477427252
########## flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/RelTreeWriterImpl.scala: ########## @@ -286,4 +297,45 @@ class RelTreeWriterImpl( }) } } + + private def copy(pw: PrintWriter): RelTreeWriterImpl = { + new RelTreeWriterImpl( + pw, + explainLevel, + withIdPrefix, + withChangelogTraits, + withRowType, + withTreeStyle, + withUpsertKey, + withQueryHint, + withQueryBlockAlias, + statementNum, + withAdvice, + withRicherDetailInSubQuery) + } + + /** + * Mainly copy from [[RexSubQuery#computeDigest]]. + * + * Modified to support explain sub-query with richer additional detail by [[RelTreeWriterImpl]] in + * Flink rather than Calcite. + */ + private def computeSubQueryRicherDigest(subQuery: RexSubQuery): String = { + val sb = new StringBuilder(subQuery.getOperator.getName); + sb.append("(") + subQuery.getOperands.forEach( + operand => { + sb.append(operand) + sb.append(", ") + }) + sb.append("{\n") + + val sw = new StringWriter + val newRelTreeWriter = copy(new PrintWriter(sw)) + subQuery.rel.explain(newRelTreeWriter) + sb.append(sw.toString) + + sb.append("})") + sb.toString() + } Review Comment: Makes sense. I lost this relationship/reasoning after force pushes :) -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org