Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-30335 [Umbrella] Improvement for Hive Query Syntax Compatibility-Part2
  3. FLINK-30452

Wrong argument type of null literal is used when call Hive's function

Attach filesAttach ScreenshotVotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      While calling Hive function, if the argument is void type, it will be considered as string type , which may bring wrong type inference and thus may well cause other problems.

       

      For example, 

      timestamp(if(a = 0, null, a))
      

      the argument for function `if` is `null` and `a`, null is void type,  `a` is bigint type represents a timestamp, so the inferred return type should be bigint for the `if` function will ignore void type and just consider the other argument type.  But we consider the void type as string type, the return type inferred will be string according to the `if` function inference logic.

      And then when we try to converted the value returned by `if(a = 0, null, a)` to timestamp, the unexpected behavior will happen:

      Since we infer the returned value of `if(a = 0, null, a)`  as string,  so  `if(a = 0, null, a)` will return some thing like "1671058803926",but 

      cast ("1671058803926" as timestamp) will return null.

       

       

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            luoyuxia luoyuxia
            luoyuxia luoyuxia
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment