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

Paweł Łoziński commented on CALCITE-4753:
-----------------------------------------

Certainly a DataContext is available when FunctionContext is being created 
[here|https://github.com/apache/calcite/blob/b2e9e6cba1e2ce28368d1281f527a9e53f4628ca/core/src/main/java/org/apache/calcite/runtime/FunctionContexts.java#L43].
 An example: [aggregate function 
instantiation|https://github.com/apache/calcite/blob/b2e9e6cba1e2ce28368d1281f527a9e53f4628ca/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java#L716].

In my use case specific characteristics of queried dataset are used to speed up 
execution (or even make it feasable in some cases). This is done by 
pre-fetching metadata (a graph structure, where some of the nodes are touched 
by the query, and the remainder is used to facilitate execution). I want to 
make this metadata available to function calls, similarly to how it's available 
in i.e. a [table 
scan|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/core/src/main/java/org/apache/calcite/schema/ScannableTable.java#L31].

Maybe there's something I'm missing about the lifecycle of a user-defined 
function, but essentially it's about sharing of the runtime context with it.

 

> Extend FunctionContext with a DataContext getter
> ------------------------------------------------
>
>                 Key: CALCITE-4753
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4753
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Paweł Łoziński
>            Priority: Major
>
> Certain functions may need access to information stored in the DataContext 
> during execution. Since it is already present in FunctionContext 
> implementation, the proposal would be to expose it via a getter.



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

Reply via email to