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

Alan Sheinberg updated FLINK-39679:
-----------------------------------
    Description: 
This test fails.  Many other implicit type conversions fail as well.
{code:java}
@Test public void testLongScalarNoCast() { 
  tEnv.createTemporarySystemFunction("func", new GreetingLongScalar());
  tEnv.executeSql("CREATE VIEW Names(name) AS VALUES ('Bob'), ('Alice'), 
('Bob')");
  final List<Row> results = executeSql("SELECT * FROM func(TABLE Names 
PARTITION BY name, 100)");
  final List<Row> expectedRows = Arrays.asList(
    Row.ofKind(RowKind.INSERT, "Bob", "Hello 100!"),
    Row.ofKind(RowKind.INSERT, "Alice", "Hello 100!"),
    Row.ofKind(RowKind.INSERT, "Bob", "Hello 100!"));
  assertThat(results).containsSequence(expectedRows); 
}
 
/** A PTF that takes an int argument and returns a greeting. */
public static class GreetingLongScalar extends ProcessTableFunction<String> {
  public void eval(
      @ArgumentHint(ArgumentTrait.SET_SEMANTIC_TABLE) Row input,
      long arg) {
    collect("Hello " + arg + "!"); 
  }
}
{code}

The intended behavior is that if an implicit cast can be done without losing 
any precision, it should "just work".  This is how other UDFs work as well.

 

  was:
This test fails.  Many other implicit type conversions fail as well.
{code:java}
@Test public void testLongScalarNoCast() { 
  tEnv.createTemporarySystemFunction("func", new GreetingLongScalar());
  tEnv.executeSql("CREATE VIEW Names(name) AS VALUES ('Bob'), ('Alice'), 
('Bob')");
  final List<Row> results = executeSql("SELECT * FROM func(TABLE Names 
PARTITION BY name, 100)");
  final List<Row> expectedRows = Arrays.asList(
    Row.ofKind(RowKind.INSERT, "Bob", "Hello 100!"),
    Row.ofKind(RowKind.INSERT, "Alice", "Hello 100!"),
    Row.ofKind(RowKind.INSERT, "Bob", "Hello 100!"));
  assertThat(results).containsSequence(expectedRows); 
}
 
/** A PTF that takes an int argument and returns a greeting. */
public static class GreetingLongScalar extends ProcessTableFunction<String> {
  public void eval(
      @ArgumentHint(ArgumentTrait.SET_SEMANTIC_TABLE) Row input,
      long arg) {
    collect("Hello " + arg + "!"); 
  }
}
{code}
 

 


> Implicit type conversion fails in code gen
> ------------------------------------------
>
>                 Key: FLINK-39679
>                 URL: https://issues.apache.org/jira/browse/FLINK-39679
>             Project: Flink
>          Issue Type: Sub-task
>            Reporter: Alan Sheinberg
>            Priority: Major
>
> This test fails.  Many other implicit type conversions fail as well.
> {code:java}
> @Test public void testLongScalarNoCast() { 
>   tEnv.createTemporarySystemFunction("func", new GreetingLongScalar());
>   tEnv.executeSql("CREATE VIEW Names(name) AS VALUES ('Bob'), ('Alice'), 
> ('Bob')");
>   final List<Row> results = executeSql("SELECT * FROM func(TABLE Names 
> PARTITION BY name, 100)");
>   final List<Row> expectedRows = Arrays.asList(
>     Row.ofKind(RowKind.INSERT, "Bob", "Hello 100!"),
>     Row.ofKind(RowKind.INSERT, "Alice", "Hello 100!"),
>     Row.ofKind(RowKind.INSERT, "Bob", "Hello 100!"));
>   assertThat(results).containsSequence(expectedRows); 
> }
>  
> /** A PTF that takes an int argument and returns a greeting. */
> public static class GreetingLongScalar extends ProcessTableFunction<String> {
>   public void eval(
>       @ArgumentHint(ArgumentTrait.SET_SEMANTIC_TABLE) Row input,
>       long arg) {
>     collect("Hello " + arg + "!"); 
>   }
> }
> {code}
> The intended behavior is that if an implicit cast can be done without losing 
> any precision, it should "just work".  This is how other UDFs work as well.
>  



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

Reply via email to