substrait icon indicating copy to clipboard operation
substrait copied to clipboard

Where can Table Function be used?

Open mbasmanova opened this issue 6 months ago • 3 comments

I'm trying to understand how to use Table Function in Substrait. I looked at the docs at https://substrait.io/expressions/table_functions/ , but there are no explanation of how to use these. Is there some other place I can check?

I'd like to find out whether I could use Table Function to implement Presto's UNNEST: https://prestodb.io/docs/current/sql/select.html#unnest

Thanks.

mbasmanova avatar Jun 30 '25 22:06 mbasmanova

Support for table functions is still something that needs to be hammered out. There's the beginnings of a conversation in https://github.com/substrait-io/substrait/issues/753.

In the meanwhile, something that I have seen done to model Unnest is the introduction of a custom Rel like

message UnnestRel {
  repeated uint32 col_refs = 1;
}

in your system for use in an ExtensionSingleRel.

vbarua avatar Jun 30 '25 23:06 vbarua

@vbarua Got it. Thank you for clarifying.

mbasmanova avatar Jun 30 '25 23:06 mbasmanova

I have opened up a draft PR here to explore implementing table functions which do not take in any relations as inputs. Please let me know what you think!

sources:

  • calcite
    • represents Table Functions as a distinct relation
    • does offer the facility to accept relational-inputs, but my PR ignores that use case for now so that it can be explored later.

benbellick avatar Oct 25 '25 20:10 benbellick