Conversation
d4a72d2 to
51300c2
Compare
Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-6-astra AI-Contributed/Feature: 0/0 AI-Contributed/UT: 110/110
51300c2 to
33b6793
Compare
| self._table = table | ||
|
|
||
| @PublicEvolving() | ||
| def flat_map( |
There was a problem hiding this comment.
Could you move it to the end of "Core Operations" group?
There was a problem hiding this comment.
Sure. Moved flat_map to the end of the “Core Operations” group.
| A reusable UDTF declaration receives a named ``Row``:: | ||
|
|
||
| >>> from pyflink.common import Row | ||
| >>> @pf.udtf |
There was a problem hiding this comment.
It's strange that when decorated with @pf.udtf, the input type is Row, otherwise, it's a dict. Why not always make it a dict?
There was a problem hiding this comment.
Make sense. flat_map now consistently passes each input row as a dict.
| for a UDTF declaration. | ||
| :return: A DataFrame containing only the emitted output columns. | ||
|
|
||
| Example:: |
There was a problem hiding this comment.
It would also be useful to demonstrate the explicit return_dtype path, the output column names, udfs defined with Callable Classes, Classes extending TableFunction, etc?
There was a problem hiding this comment.
It seems that it doesn't support callable class? It worth to support it also.
There was a problem hiding this comment.
Agreed. Callable instances were already supported. Added support for passing callable classes directly to flat_map and pf.udtf.
Added examples for explicit return_dtype and output column names, plus callable class and TableFunction examples.
|
Another problem worth to address: this change introduces the public
As a result, explicit binding currently fails before SQL planning: source = pf.from_dict({"text": ["ab"]})
@pf.udtf(return_dtype=str)
def chars(text):
yield from text
pf.sql(
"SELECT ch FROM source, LATERAL TABLE(chars(text)) AS T(ch)",
auto_bind=False,
source=source,
chars=chars,
) |
…taFrame UDTFs AI-Contributed/Feature: 0/312 AI-Contributed/UT: 0/318
@dianfu Thanks for catching this! Added UDTF support to explicit binding validation, auto-binding discovery, and function registration. |
What is the purpose of the change
This PR implements FLINK-40434 by adding DataFrame.flat_map for transforming each input row into zero or more output rows. It also introduces pf.udtf for reusable table function declarations. The transformation is lazy and produces only the UDTF output columns.
Brief change log
Add DataFrame.flat_map and pf.udtf, supporting Python callables and TableFunction instances or classes.
Support explicit output types and inference from iterable return annotations, preserving named output fields.
Provide dictionary input for plain callables and named Row input for UDTF declarations in both process and thread modes.
Add API documentation and examples.
Verifying this change
his change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Codex(GPT-6)