Repository navigation
feat(core): support table functions - #1468
Draft
Adam-Alani wants to merge 6 commits into
Draft
Adam-Alani wants to merge 6 commits into
Adam-Alani wants to merge 6 commits into
Conversation
Apply the read filter before selecting columns, and apply emit to the projected schema. Preserve the field order of the mask on named tables, virtual tables and local files. BREAKING CHANGE: Spark now applies whole-column read masks in selection order and rejects unsupported nested read masks.
Read and write detached relations without losing opaque references. Accept named-lambda capability declarations and report unsupported plan definitions. Supply the execution timezone for calendar arithmetic on zoned timestamps and match each overload against its argument count. BREAKING CHANGE: Replace the removed subtract:ptstz_iyear overload with subtract:ptstz_iyear_str and supply an IANA timezone or the current_timezone expression.
The datetime mapper runs before default matching. It claimed year/month arithmetic on a zoned timestamp even when another extension declares the two operands, and replaced that call with the standard three-argument function. The mapper now leaves a call to default matching when a declaration matches the operand types exactly. In the other direction, a standard call keeps its current_timezone argument when the two remaining operands would convert to that declaration.
… operands The check that decides whether an aggregate needs a carried binding took the first declaration with a matching signature. Conversion from Calcite prefers a later declaration when the first one does not bind the operands. The check now applies the same operand test, so the binding stays in that case.
Spec v0.109.0 requires a UUID literal to be exactly 16 bytes in network byte order. Java already encoded and decoded big-endian, but decoding read the first 16 bytes of a longer value and failed with a BufferUnderflowException on a shorter one. It now rejects any other length with an IllegalArgumentException. The release also adds table functions, whose functions_table.yaml the extension model cannot read yet, so the default catalog leaves it out until they are modeled. BREAKING CHANGE: converting a UUID literal whose bytes are not exactly 16 long now throws IllegalArgumentException instead of decoding the first 16 bytes.
Substrait v0.109.0 adds table functions. An extension declares them under table_functions, with an optional schema in place of a return type, and a TableFunctionRel calls one to produce zero or more rows. Its arguments may reference outer rows, so on the right of a lateral join it produces rows for each left row. The extension model now reads table_functions, and the default catalog loads functions_table.yaml, which declares generate_series. A new TableFunction relation converts to and from TableFunctionRel, and a dialect can declare the TABLE_FUNCTION relation and supported_table_functions. Isthmus and Spark do not convert table functions yet.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Substrait v0.109.0 adds table functions, which produce zero or more rows per call. An extension declares them under
table_functions, with an optionalschemain place of a return type, and aTableFunctionRelcalls one as a leaf relation. Its arguments may reference outer rows, so on the right of a lateral join it produces rows for each left row, for examplegenerate_series(1, n, 1)for eachn. substrait-java could neither load these declarations nor read or write the relation.What
table_functions, and the default catalog loadsfunctions_table.yaml, which declaresgenerate_series.TableFunctionrelation, built withSubstraitBuilder.tableFunction, converts to and fromTableFunctionRel, and the copy-on-write visitor rewrites its arguments.TABLE_FUNCTIONrelation andsupported_table_functions.How
A table function implementation is modeled as a
SimpleExtension.TableFunctionVariant: aFunctionwhose return type is the YAMLschema, so argument conversion, function anchors and the extension collector work unchanged. When an implementation omits the schema the producer determines it, so resolving the output type from the declaration throws. The relation always carries the concrete, non-nullable schema from the plan, and converting aTableFunctionRelwithout one is rejected.ExtensionLookup.getTableFunctionis a default method, so existing lookup implementations keep compiling.The tests round-trip both
generate_seriessignatures, a lateral join whose table function arguments reference the left row, and the spec'slateral_generate_seriesexample as a whole plan. They also cover the rejection of a nullable or missing schema and of a reference to a function that is not a table function, and how a schema is resolved from a declaration.