You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "herodu (Jira)" <ji...@apache.org> on 2021/03/04 06:35:00 UTC

[jira] [Updated] (CALCITE-4521) Support User Defined Table-valued Function

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

herodu updated CALCITE-4521:
----------------------------
    Description: 
It already support TUMBLE/HOP/SESSION windowing table-valued function in current version. But in fact, the table-valued function is not just the current features, so we want to support user defined table-valued function, just like the following query:
{code:java}
// code placeholder
select * from table(UDTVF(table Shipments))
{code}
or
{code:java}
// code placeholder
select * from table(UDTVF(select * from Shipments)){code}
The input parameters of 'UDTVF' is the output rowtype of the inner subquery, and the output of 'UDTVF' is defined by user, like: 
{code:java}
// code placeholder
final TableValuedFunction tableValuedFunction =
    (RelDataTypeFactory typeFactory) -> typeFactory.builder()
        .add("in1", SqlTypeName.INTEGER)
        .add("in2", SqlTypeName.VARCHAR)
        .build();
{code}
 

And the expected output logic plan like: 
{code:java}
// code placeholder
LogicalProject(in1=[$0], in2=[$1])
  LogicalTableFunctionScan(invocation=[UDTVF($0, $1)], rowType=[RecordType(INTEGER in1,VARCHAR in2)])
    LogicalProject(ORDERID=[$0], ROWTIME=[$1])
      LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
{code}
 

 

  was:
It already support TUMBLE/HOP/SESSION windowing table-valued function in current version. But in fact, the table-valued function is not just the current features, so we want to support user defined table-valued function, just like the following query:

 
{code:java}
// code placeholder
select * from table(UDTVF(table Shipments))
{code}
or

 

 
{code:java}
// code placeholder
select * from table(UDTVF(select * from Shipments)){code}
 

The input parameters of 'UDTVF' is the output rowtype of the inner subquery, and the output of 'UDTVF' is defined by user, like: 

 
{code:java}
// code placeholder
final TableValuedFunction tableValuedFunction =
    (RelDataTypeFactory typeFactory) -> typeFactory.builder()
        .add("in1", SqlTypeName.INTEGER)
        .add("in2", SqlTypeName.VARCHAR)
        .build();
{code}
 

And the expected output logic plan like: 

 
{code:java}
// code placeholder
LogicalProject(in1=[$0], in2=[$1])
  LogicalTableFunctionScan(invocation=[UDTVF($0, $1)], rowType=[RecordType(INTEGER in1,VARCHAR in2)])
    LogicalProject(ORDERID=[$0], ROWTIME=[$1])
      LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
{code}
 

 


> Support User Defined Table-valued Function
> ------------------------------------------
>
>                 Key: CALCITE-4521
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4521
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: herodu
>            Priority: Major
>
> It already support TUMBLE/HOP/SESSION windowing table-valued function in current version. But in fact, the table-valued function is not just the current features, so we want to support user defined table-valued function, just like the following query:
> {code:java}
> // code placeholder
> select * from table(UDTVF(table Shipments))
> {code}
> or
> {code:java}
> // code placeholder
> select * from table(UDTVF(select * from Shipments)){code}
> The input parameters of 'UDTVF' is the output rowtype of the inner subquery, and the output of 'UDTVF' is defined by user, like: 
> {code:java}
> // code placeholder
> final TableValuedFunction tableValuedFunction =
>     (RelDataTypeFactory typeFactory) -> typeFactory.builder()
>         .add("in1", SqlTypeName.INTEGER)
>         .add("in2", SqlTypeName.VARCHAR)
>         .build();
> {code}
>  
> And the expected output logic plan like: 
> {code:java}
> // code placeholder
> LogicalProject(in1=[$0], in2=[$1])
>   LogicalTableFunctionScan(invocation=[UDTVF($0, $1)], rowType=[RecordType(INTEGER in1,VARCHAR in2)])
>     LogicalProject(ORDERID=[$0], ROWTIME=[$1])
>       LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)