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

Mika Naylor updated FLINK-39253:
--------------------------------
    Issue Type: Improvement  (was: Bug)

> row() does not preserve field names from AS aliases and field references
> ------------------------------------------------------------------------
>
>                 Key: FLINK-39253
>                 URL: https://issues.apache.org/jira/browse/FLINK-39253
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API, Table SQL / Planner
>            Reporter: Mika Naylor
>            Assignee: Mika Naylor
>            Priority: Major
>              Labels: pull-request-available
>
> The {{row()}} function currently ignores field names/aliases provided through 
> {{AS}} expressions or field references, always generating default names 
> ({{{}f0, f1, f2, etc.{}}}) instead.
> When creating a ROW with explicitly named fields using AS aliases or field 
> references, the resulting ROW type should preserve those names:
>  
> {code:java}
> row($("f0").as("customer_id"), $("f1").as("product_id"))
> // Should produce: ROW<customer_id INT, product_id STRING>{code}
>  
> but in actuality, the field names are lost and default names are used
>  
> {code:java}
> row($("f0").as("customer_id"), $("f1").as("product_id"))
> // Currently produces: ROW<f0 INT, f1 STRING> {code}
> This makes the following kinds of expressions impossible:
>  
> {code:java}
> env.from("example_order_passthrough")
>         .select(
>                 $("order_id"),
>                 row(
>                                 $("customer_id").as("customer_id"),
>                                 $("product_id").as("product_id"),
>                                 $("price").as("price"))
>                         .as("details"))
>         .where($("details").get("price").isGreaterOrEqual(50))
>         .execute()
>         .print(); {code}
> as they fail with:
>  
> {code:java}
> Exception in thread "main" org.apache.flink.table.api.ValidationException: 
> Invalid function call:
> get(ROW<`f0` INT, `f1` STRING, `f2` DOUBLE> NOT NULL, CHAR(5) NOT NULL) {code}
> Necessitating either using {{f2}} or using a cast as a workaround.
>  



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

Reply via email to