-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymorphic table functions #1839
Comments
How's it going now? |
I guess this would be like MSSQL 'Linked Server' functionality: https://docs.microsoft.com/en-us/sql/t-sql/functions/openquery-transact-sql?view=sql-server-ver15 / https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/linked-servers-database-engine?view=sql-server-ver15 |
The issue looks old, is there any interest in implementing table functions at the moment? It would be great if we can add the support for syntax as a start. |
#11336 is just merged |
Quick question: will mutation be supported? Sometimes we issue multi-statement query(or just a stored procedure) on target database, where the last statement is for updating. I noticed |
@zhicwu you may want to see #12322
#12325 is by design for queries reading data. |
Thanks @findepi. Does it make sense to you to support PTF by both embedded jdbc connector and external bridge server? I think clickhouse-jdbc-bridge is something very similar to the latter. It's just an inmature thought, but maybe I can rewrite jdbc bridge to benefit both sides. |
Add support for polymorphic table functions (https://www.iso.org/standard/69776.html)
related PRs:
#11336
#12350
#12338
This document was moved from: #11937
It serves the following purposes:
Definitions
A Table Function is a function which returns a relation, as opposed to a scalar function which returns a single value.
A Polymorphic Table Function (PTF) is a Table Function which fulfils at least one of the following conditions:
Specifically, the output type of the Polymorphic Table Function may depend on the arbitrary table passed as an argument.
Scope of the task
The scope of the task is to provide full support for Table Functions, including Polymorphic Table Functions.
Subtasks
Add language support for PTF invocation
Add SPI support for declaring PTFs by connectors
ConnectorTableFunction
analyze()
: a method for required and custom analysisAnalysis
: a class to provide the required and custom analysis results to Trino AnalyzerConnectorTableFunctionHandle
: an interface for passing the custom analysis resultsfulfil()
: a method to provide the function logic to TrinoAdd mechanism for registering PTFs
Analyze PTF invocation
Plan PTF invocation
TableFunctionNode
Execute PTF through pushdown to connector
apply()
methodsRewriteTableFunctionToTableScan
Optimizer ruleAdd example PTF implementations: query pass-through
query
function for JDBC connectors:raw_query
function for Elasticsearch connectorAchieved functionality
Currently, any PTF can be supported, which can be entirely realised by a connector. The connector can "capture" the PTF invocation, and replace it with a ConnectorTableHandle, which represents the PTF result.
Following work
To provide full support for PTF, as in the SQL standard, we need to:
TableFunctionNode
: column pruning, etcTableFunctionNode
in AddExchanges / AddLocalExchanges: realise the partitioning and ordering of input tables respecting their actual properties. Also, consider the output properties ofTableFunctionNode
.fulfil()
method), and the Operator: in what form data will be provided to the PTF logic, and in what form the results will be returned to the OperatorFollow-ups
Possible improvements to be implemented if desired:
TableFunctionProcessorNode
withHashGenerationOptimizer
. notes: requires outputting the hash symbol; hash symbol has no marker symbol.The text was updated successfully, but these errors were encountered: