[ 
https://issues.apache.org/jira/browse/FLINK-9229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16449788#comment-16449788
 ] 

ASF GitHub Bot commented on FLINK-9229:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5898#discussion_r183716031
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
 ---
    @@ -1274,30 +1276,46 @@ abstract class CodeGenerator(
           literalType: TypeInformation[_],
           literalCode: String)
         : GeneratedExpression = {
    +
    +    // mark this expression as a constant literal
    +    generateTerm(literalType, literalCode).copy(literal = true)
    +  }
    +
    +  private[flink] def generateSymbol(enum: Enum[_]): GeneratedExpression = {
    +    GeneratedExpression(
    +      qualifyEnum(enum),
    +      "false",
    +      "",
    +      new GenericTypeInfo(enum.getDeclaringClass))
    +  }
    +
    +  /**
    +    * Generates access to a term (e.g. a field) that does not require 
unboxing logic.
    +    *
    +    * @param fieldType type of field
    +    * @param fieldTerm expression term of field (already unboxed)
    +    * @return internal unboxed field representation
    +    */
    +  private[flink] def generateTerm(
    +      fieldType: TypeInformation[_],
    +      fieldTerm: String)
    +    : GeneratedExpression = {
         val resultTerm = newName("result")
         val nullTerm = newName("isNull")
    --- End diff --
    
    If the `nullTerm` is constant, couldn't we say `nullTerm = "false";` and 
simplify the remaining code?


> Fix literal handling in code generation
> ---------------------------------------
>
>                 Key: FLINK-9229
>                 URL: https://issues.apache.org/jira/browse/FLINK-9229
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API & SQL
>    Affects Versions: 1.4.2
>            Reporter: Timo Walther
>            Assignee: Timo Walther
>            Priority: Major
>
> Information about expressions that are constant help during code generation. 
> Especially when moving often reused parts of code in the member area of a 
> generated function. Right now this behavior is not consistent because even 
> methods in {{generateFieldAccess}} generate literals but they are not 
> constant. This could lead to unintended behavior.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to