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

Julian Hyde commented on CALCITE-4521:
--------------------------------------

I'm been doing this work reactively, to get my Morel project to work, but I 
haven't had time to work on test cases. It would be really helpful if you could 
write a test case, and also think about/document how users should go about 
writing these kinds of UDFs.

For example, a particular use case I had was to create the TableFunctionScan 
via RelBuilder, and I wanted to pass the type as an argument whose value was 
JSON string. I found that RexCallBinding did not have the method to access that 
argument at prepare time.

If you add some more test cases about how UDTFs derive their type, it would be 
helpful. Also, my UDTF had no inputs; a UDTF with 1 or 2 inputs, that somehow 
derives its type from the types of those inputs, would also be useful.

> 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, and we want to support user defined table-valued function, 
> just like the following query:
> {code:java}
> select * from table(UDTVF(table Shipments))
> {code}
> or
> {code:java}
> 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 users, just like: 
> {code:java}
> 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}
> 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)

Reply via email to