You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jing Zhang (Jira)" <ji...@apache.org> on 2022/12/27 07:11:00 UTC

[jira] [Closed] (FLINK-30452) Wrong argument type of null literal is used when call Hive's function

     [ https://issues.apache.org/jira/browse/FLINK-30452?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Zhang closed FLINK-30452.
------------------------------
    Assignee: luoyuxia

> Wrong argument type of null literal is used when call Hive's function
> ---------------------------------------------------------------------
>
>                 Key: FLINK-30452
>                 URL: https://issues.apache.org/jira/browse/FLINK-30452
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Connectors / Hive
>            Reporter: luoyuxia
>            Assignee: luoyuxia
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.17.0
>
>
> While calling Hive function, if the argument is void type, it will be [considered as string type|[https://github.com/apache/flink/blob/2e5cac1f31aa571276df20e24889994672692a89/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/functions/hive/conversion/HiveInspectors.java#L553]] , which may bring wrong type inference and thus may well cause other problems.
>  
> For example, 
> {code:java}
> timestamp(if(a = 0, null, a))
> {code}
> 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.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)