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

Ramin Gharib updated FLINK-38083:
---------------------------------
    Description: 
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:
```sql
Type1Constructor(f0, f1) = OBJECT_OF('com.example.Type1', 'a', 42, 'b', 'Bob')
```

The error output would be
```
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>.
```

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", f0, "b", f1) would yeeled:
{code:java}
"STRUCTURED<'type2class', `a` INT NOT NULL, `b` CHAR(3) NOT NULL>"  {code}
This will cause failure in equal expressions.

 

  was:
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}
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}
For the 
{noformat}
ROW(42, "Bob"){noformat}

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", f0, "b", f1) would yeeled:
{code:java}
"STRUCTURED<'type2class', `a` INT NOT NULL, `b` CHAR(3) NOT NULL>"  {code}

This will cause failure in equal expressions.

 


> 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:
> ```sql
> Type1Constructor(f0, f1) = OBJECT_OF('com.example.Type1', 'a', 42, 'b', 'Bob')
> ```
> The error output would be
> ```
> 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>.
> ```
> 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", f0, "b", f1) would yeeled:
> {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