Skip to content

[FLINK-40186][python] Introduce the PyFlink DataFrame API#28797

Open
auroflow wants to merge 4 commits into
apache:masterfrom
auroflow:auroflow/flink-40185-dataframe
Open

[FLINK-40186][python] Introduce the PyFlink DataFrame API#28797
auroflow wants to merge 4 commits into
apache:masterfrom
auroflow:auroflow/flink-40185-dataframe

Conversation

@auroflow

Copy link
Copy Markdown
Contributor

What is the purpose of the change

This pull request introduces the foundation for a Pythonic DataFrame API in PyFlink.

Brief change log

  • Add the pyflink.dataframe package and its public evolving interfaces.
  • Add DataFrame creation from column-oriented dictionaries and row-oriented records, including mappings, named tuples, and general sequences.
  • Add column selection, filtering, column addition or replacement, item access, and result collection.
  • Add column and literal expressions, including explicitly typed and null literals.
  • Add configurable TableEnvironment lifecycle functions.
  • Add schema, record, expression, and environment validation.
  • Include the DataFrame package in packaging and static type checking.
  • Add unit and end-to-end tests for the introduced functionality.

Verifying this change

This change added tests and can be verified as follows:

  • Added tests for DataFrame creation, schema inference and validation, mappings, named tuples, and general sequence records.
  • Added tests for selection, filtering, callable expressions, column replacement, item access, typed literals, and result collection.
  • Added tests for TableEnvironment configuration and lifecycle handling.

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): yes
  • 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? PyDocs

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: OpenAI Codex (GPT-5.6 Sol)

auroflow added 4 commits July 22, 2026 11:56
Generated-by: OpenAI Codex (GPT-5.6 Sol)
Generated-by: OpenAI Codex (GPT-5.6 Sol)
Generated-by: OpenAI Codex (GPT-5.6 Sol)
Generated-by: OpenAI Codex (GPT-5.6 Sol)
@dianfu dianfu changed the title [FLINK-40185][python] Introduce the PyFlink DataFrame API [FLINK-40186][python] Introduce the PyFlink DataFrame API Jul 22, 2026
@flinkbot

flinkbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@auroflow
auroflow force-pushed the auroflow/flink-40185-dataframe branch from 1b7cd38 to 9684ffc Compare July 22, 2026 05:41

self.assertEqual(result.collect(), [Row(1, "Alice", 31)])

def test_from_dict_respects_schema_order_and_subset(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has introduced about 30 it cases. Please check if we could merge them. Besides, it's also worth to check if it's possible to convert part of them into unit tests.

)
field_rows.append(tuple(field_values[name] for name in columns))
rows = field_rows
elif isinstance(first_record, Sequence):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isinstance(record, Sequence) check also accepts str, bytes, and similar scalar values. For example: from_records(["ab", "cd"], schema=["x", "y"]) produces rows ("a", "b") and ("c", "d") which is not expected.


.. versionadded:: 2.4.0
"""
if not isinstance(data, Mapping):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column validation also accepts strings because they implement Sequence:
from_dict({"name": "Bob"}) would create three rows containing "B", "o", and "b".



@PublicEvolving()
def set_table_environment(t_env: Optional["StreamTableEnvironment"]) -> None:

@dianfu dianfu Jul 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate the type of the given t_env

for name in columns:
if name not in field_values:
raise ValueError(
"schema field %r is not present in records" % name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since validation is performed per record, the message should identify the failing index consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants