-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Implement table function source #14566
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
Conversation
b1a3258 to
f66cf93
Compare
da3abf4 to
2bcc444
Compare
2bcc444 to
e7532c4
Compare
7c8b0f2 to
8163379
Compare
8163379 to
3a1c7f0
Compare
3c567ec to
5ab991d
Compare
5ab991d to
a47c5c9
Compare
a47c5c9 to
f3792b4
Compare
2f9d775 to
0a1cd98
Compare
0a1cd98 to
c0fead5
Compare
c2b35d8 to
c248039
Compare
core/trino-main/src/main/java/io/trino/sql/planner/plan/TableFunctionNode.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/plan/TableFunctionProcessingNode.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why special case for when there are two or more sources? Can we just treat everything uniformly even if there's a single source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, we could let a single source through the whole algorithm. However, the marker symbols, and all the other "helper" symbols only make sense when you need to make a cross-product of partitions from 2+ sources. The algorithm appends many stages of processing, including window operations (which wouldn't get pruned afterwards for a single source, if we really treated it uniformly).
Another argument for special handling the case of a single source is for code readability in what is probably going to be the most common case.
core/trino-main/src/main/java/io/trino/sql/planner/optimizations/SymbolMapper.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/plan/TableFunctionProcessingNode.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
f204add to
79b04f7
Compare
|
@martint I applied your comments, rebased, and squashed the rule into one commit. PTAL |
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
...ino-main/src/main/java/io/trino/sql/planner/iterative/rule/ImplementTableFunctionSource.java
Outdated
Show resolved
Hide resolved
.../trino-main/src/test/java/io/trino/sql/planner/assertions/TableFunctionProcessorMatcher.java
Outdated
Show resolved
Hide resolved
.../trino-main/src/test/java/io/trino/sql/planner/assertions/TableFunctionProcessorMatcher.java
Outdated
Show resolved
Hide resolved
Change the builder for TableArgumentSpecification so that there is no default for the empty behavior.
…tput If a table function has multiple partitioned inputs, they might be co-partitioned. Co-partitioning might require coercing of the corresponding partitioning columns to common supertype. Additionally, each partitioning source column should be produced on table function's output in its original (uncoerced) form. Before this change, the coerced columns were incorrectly passed to output. After this change, the uncoerced columns are preserved for output independently from the Specification, which is planned with regard to the required co-partitioning coercions.
Adds the SchemaFunctionName, which can act as a unique identifier of the function for a given catalog.
the necessary pass-through information for a table function's source includes: - whether the source was declared as pass-through - an ordered list of pass-through columns - for each column, information whether it is a partitioning column
When the ordering scheme is mapped, some symbols might be removed due to de-duplication. If de-duplication happens within the pre-sorted prefix, the length of the prefix should be updated. This causes no issues currently, since UnaliasSymbolReferences, and so the SymbolMapper, is never called after AddLocalExchanges, where the pre-sorted symbols are determined.
In case when there are no input tables for a table function invocation, the resulting TableFunctionProcessingNode has no soures. Otherwise, it has one source being a combination of all inputs.
Support arbitrary number of sources (including no sources), involving row and set semantics, prune/keep when empty properties, and co-partitioning.
79b04f7 to
ed5cc54
Compare
Description
This PR adds an iterative rule
ImplementTableFunctionSourcewhich transforms (potentially) multiple sources of aTableFunctionNodeinto a single source. The rule joins the sources according to their partitioning, ordering, co-partitioning and prune when empty properties.This PR also introduces a new PlanNode to represent the table function invocation with pre-processed source:
TableFunctionProcessingNode.note: the rule is quite complicated, so the implementation was split into three steps, each covering some area. I meant to squash them after the review, but it would be also correct to merge them separately.
Release notes
(x ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: