JingsongLi commented on a change in pull request #16420:
URL: https://github.com/apache/flink/pull/16420#discussion_r666632299



##########
File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/GenerateUtils.scala
##########
@@ -176,7 +184,15 @@ object GenerateUtils {
     val resultTerm = ctx.addReusableLocalVariable(resultTypeTerm, "result")
     val isResultNullable = resultNullable || (isReference(returnType) && 
!isTemporal(returnType))
     val nullTermCode = if (ctx.nullCheck && isResultNullable) {
-      s"$nullTerm = ($resultTerm == null);"
+      // we assume that result term of a primitive SQL type will never be null,
+      // violating this assumption might cause null pointer exception 
somewhere else.
+      // when using this column we'll first check its null term.
+      s"""
+         |$nullTerm = ($resultTerm == null);

Review comment:
       I'm worried about adding a few lines of code here. This is the only way 
for each call, which will increase the code generated by CodeGen.
   
   Can we just fix the result term or add null check in the `CalcCodeGenerator`?




-- 
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]


Reply via email to