lsyldliu commented on code in PR #22734:
URL: https://github.com/apache/flink/pull/22734#discussion_r1242115813
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/GeneratedExpression.scala:
##########
@@ -101,6 +108,37 @@ case class GeneratedExpression(
this
}
}
+
+ /** Deep copy code of mutable field generated expression. */
+ def deepCopyMutableExpr(ctx: CodeGeneratorContext): String = {
+ // only copy when type is mutable
+ if (TypeCheckUtils.isMutable(resultType)) {
+ deepCopy(ctx).getCode
+ } else {
+ ""
+ }
+ }
+
+ def getCode(): String = {
+ codeUsed match {
+ // if the code has been wrapped into generated code block, doesn't
evaluate it again
+ case true => NO_CODE
+ case false =>
+ codeUsed = true
+ code
+ }
+ }
+
+ /**
+ * This is used only for OFCG, we need to copy the expr to avoid the code is
used when prepare
+ * rowVar.
+ */
+ def copyExpr(): GeneratedExpression = {
+ codeUsed match {
+ case true => GeneratedExpression(resultTerm, nullTerm, NO_CODE,
resultType, literalValue)
+ case false => GeneratedExpression(resultTerm, nullTerm, code,
resultType, literalValue)
+ }
+ }
Review Comment:
Yes, I agree with you.
--
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]