autophagy opened a new pull request, #29498:
URL: https://github.com/apache/flink/pull/29498
## What is the purpose of the change
This change extends the type inference for `TypedDict` to other composite
classes, specifically `dataclass`, `typing.NamedTuple` and fixed length
`tuple`, so that they are then mapped to a corresponding `ROW`.
For both `TypedDict` and `dataclass`, the column names are taken from the
fields. For `tuple`, it instead uses a positional naming of `_1`, `_2`, etc. In
the DataFrame API, an explicit UDTF `return_dtype=Tuple[...]` now produces the
same positional `f0`/`f1` fields as an annotated `Iterator[Tuple[...]]`.
This PR also has a behaviour change in that an empty `TypedDict` used to
infer to a `ROW<>`, and now it rejects these, matching the java behaviour when
trying to infer a structured type from a class with no fields.
## Brief change log
- Extended Python type inference for Dataframe API to support `dataclass`,
`NamedTuple` and `tuple` types.
- Changed behaviour when inferring from a `TypedDict` with no fields so that
they are rejected.
## Verifying this change
This change added tests and can be verified as follows:
- Added tests to cover the new behaviour in both the `test_typehints` tests
and across the dataframe api's udf/udtf etc tests.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (yes)
- If yes, how is the feature documented? (not applicable)
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please
change the checkbox below to `[X]` and replace the placeholder in the
"Generated-by"
line with the tool name and version. Otherwise remove the "Generated-by"
line.
See the ASF Generative Tooling Guidance for details:
https://www.apache.org/legal/generative-tooling.html
You are responsible for the quality and correctness of every change in this
PR
regardless of the tooling used. Low-effort AI-generated PRs will be closed.
See
AGENTS.md for the full guidance.
-->
- [x] Yes (please specify the tool below)
Generated-by: opus 5.5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]