Skip to content

[FLINK-40417][python] Add remaining basic functionality to DataFrame API - #29002

Open
auroflow wants to merge 2 commits into
apache:masterfrom
auroflow:auroflow/codex/flink-40417-dataframe-basics
Open

[FLINK-40417][python] Add remaining basic functionality to DataFrame API#29002
auroflow wants to merge 2 commits into
apache:masterfrom
auroflow:auroflow/codex/flink-40417-dataframe-basics

Conversation

@auroflow

Copy link
Copy Markdown
Contributor

What is the purpose of the change

This pull request completes the remaining core PyFlink DataFrame ergonomics defined by the DataFrame API FLIP. It adds the remaining basic column transformations, functional composition support, filtering aliases, and schema metadata properties.

Brief change log

  • Add DataFrame.with_columns() for adding or replacing multiple columns.
  • Add DataFrame.drop_columns() and its drop alias.
  • Add DataFrame.rename_columns() and its rename alias, supporting mappings, callables, and positional name pairs.
  • Add DataFrame.pipe() and the where alias for filter.
  • Add the schema and columns properties.
  • Update the DataFrame API reference and public API docstrings.

Verifying this change

This change added tests and can be verified as follows:

  • Added planner-backed unit coverage for with_columns, column dropping and renaming, and schema metadata properties.
  • Added environment-independent unit coverage for pipe argument forwarding, return values, and alias identity.
  • Extended DataFrameITTests.test_basic_functionality so the new transformations participate in its existing single executed job.

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? DataFrame API reference and Python API docstrings

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

Generated-by: Codex (GPT-5)

@flinkbot

flinkbot commented Aug 21, 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


>>> import pyflink.dataframe as pf
>>> df = pf.from_records([(2, 3)], schema=["left", "right"])
>>> result = df.with_columns(

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.

We can also add an example for named arguments

@auroflow auroflow Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I added two separate examples for positional and named arguments.

>>> import pyflink.dataframe as pf
>>> df = pf.from_records([(1, "Alice")], schema=["id", "name"])
>>> by_mapping = df.rename_columns({"id": "user_id"})
>>> by_callable = df.rename(str.upper)

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.

Could you also add an lambda function example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, now I use a lambda function explicitly.

def rename_columns(
self,
*args: Any,
mapping: Optional[

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 seems that the args isn't that necessary. Removing it will make the API more clear.

@auroflow auroflow Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The *args is primarily used to support passing a list of alternating old and new name pairs. For example,

by_pairs = df.rename("id", "user_id", "name", "user_name")

I have updated the docstring to explain this usage more clearly.

)
.drop("score", "city", "destination")
.rename({"name": "customer_name"})
.pipe(

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.

I think we can call .select directly. pipe is already welled tested in test_pipe_forwards_dataframe_arguments_and_return_value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, pipe does not involve runtime logic. I have removed this call.

"non_nullable_int",
],
)
self.assertEqual(result.schema.get_field_names(), result.columns)

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's not that necessary to validate this any more in IT case. It's already covered in test_schema_exposes_ordered_metadata and test_columns_returns_defensive_ordered_list

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I removed this validation.

Clarify usage forms in the public docstrings and remove redundant integration-test coverage.

Generated-by: Codex (GPT-5)
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