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

Ramin Gharib commented on FLINK-38083:
--------------------------------------

[~maheshsambaram] Hello,
You still need to wait for my PR on `OBJECT_OF` function support to be merged. 
[https://github.com/apache/flink/pull/26704] 
You will find a test in the `StructuredFunctionsITCase` that is commented out 
and would reproduce this bug.

> OBJECT_OF function's type don't get inferred correctly during comparison 
> -------------------------------------------------------------------------
>
>                 Key: FLINK-38083
>                 URL: https://issues.apache.org/jira/browse/FLINK-38083
>             Project: Flink
>          Issue Type: Sub-task
>            Reporter: Ramin Gharib
>            Priority: Minor
>
> Whenever we compare a structure type in the example below with one that was 
> created through the `OBJECT_OF` function, the types don't match correctly. 
> {code:java}
> pacakge com.example;
> public static class Type1 {
> public Integer a;
> public String b;
> public static class Type1Constructor extends ScalarFunction {
>     public Type1 eval(Integer a, String b) {
>        final Type1 t = new Type1();
>        t.a = a;
>        t.b = b;
>        return t;
>     }
> }
> // getter and setters
> }
> {code}
> If we have a table with a row of:
> {noformat}
> ROW(42, "Bob"){noformat}
> If we run the statement:
> {code:java}
> Type1Constructor(f0, f1) = OBJECT_OF('com.example.Type1', 'a', 42, 'b', 
> 'Bob'){code}
> The error output would be
> {code:java}
> org.apache.flink.table.api.ValidationException: Incompatible structured 
> types: 
> STRUCTURED<'org.apache.flink.table.planner.functions.StructuredFunctionsITCase$Type1',
>  `a` INT, `b` STRING> and 
> STRUCTURED<'org.apache.flink.table.planner.functions.StructuredFunctionsITCase$Type1',
>  `a` INT NOT NULL, `b` CHAR(3) NOT NULL>.{code}
> In SQL and TableAPI, the returned type of `Type1Constructor(f0, f1)` would be 
> a
> {code:java}
> "STRUCTURED<'type1class', `a` INT, `b` STRING>" {code}
> where as the `OBJECT_OF(Type1.class, "a", 42, "b", 'Bob')` yeeleds:
> {code:java}
> "STRUCTURED<'type2class', `a` INT NOT NULL, `b` CHAR(3) NOT NULL>"  {code}
> This will cause failure in equal expressions.
>  



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

Reply via email to