[FLINK-39377][table] Add initial implementation of ProcessTableFunctionTestHarness#27928
Open
autophagy wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39377][table] Add initial implementation of ProcessTableFunctionTestHarness#27928autophagy wants to merge 1 commit intoapache:masterfrom
autophagy wants to merge 1 commit intoapache:masterfrom
Conversation
…onTestHarness This commit introduces an initial implementation of a test harness for PTFs, for use in unit tests that do not require a running Flink cluster. The implementation supports setting up the harness by configuration various test parameters, like fixtures for scalar arguments, datatypes for table arguments and partition settings for table arguments with set semantics. The harness on build does type and structure validation, as well as ensuring the test setup can handle the arguments defined on the PTF. It supports PTFs that use scalar, set semantic table and row semantic table arguments, as well as PTFs that have multiple of each. It supports PASS_COLUMN_THROUGH and OPTIONAL_PARTITION_BY traits. It currently does not support State, or Context (so no timers). It also does not enforce some static argument traits like SUPPORTS_UPDATES, REQUIRE_UPDATE_BEFORE.
spuru9
reviewed
Apr 15, 2026
Contributor
spuru9
left a comment
There was a problem hiding this comment.
Some nits from early review. PTAL
| private final HarnessCollector collector; | ||
|
|
||
| private final String defaultTableArgument; | ||
| private final java.lang.reflect.Method evalMethod; |
Contributor
There was a problem hiding this comment.
java.lang.reflect.Method can be imported in the top section.
Same can be done for all others from reflect.*.
| @@ -0,0 +1,361 @@ | |||
| --- | |||
Contributor
There was a problem hiding this comment.
The testing/ directory is missing an _index.md (needed to show the section in the sidebar). Could you add one following the pattern of the sibling directories like functions/?
| && activeTableArg.partitionColumnNames.length > 0 | ||
| ? String.format( | ||
| ", partition columns: %s", | ||
| java.util.Arrays.toString( |
Contributor
There was a problem hiding this comment.
nit: import java.util.Arrays
| * <pre>{@code | ||
| * ProcessTableFunctionTestHarness<Row> harness = | ||
| * ProcessTableFunctionTestHarness.ofClass(MyPTF.class) | ||
| * .withTableArgumentType("input", DataTypes.of("ROW<id INT, name STRING>")) |
Contributor
There was a problem hiding this comment.
Suggested change
| * .withTableArgumentType("input", DataTypes.of("ROW<id INT, name STRING>")) | |
| * .withTableArgument("input", DataTypes.of("ROW<id INT, name STRING>")) |
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.
What is the purpose of the change
This change introduces an initial implementation of a test harness for PTFs, according to FLIP-567, for use in unit tests that do not require a running Flink cluster.
At a basic level, the harness allows users to set up test conditions with a builder API, which on build performs both test and PTF validation, and provides an auto-closable harness (that manages open/close). With this harness, users are able to pipe input rows into their PTF, and observe the collected output.
A motivating example:
It currently supports:
PASS_COLUMNS_THROUGHandOPTIONAL_PARTITION_BYargument traits.The harness currently does not support the following, which will be added in subsequent PRs:
SUPPORTS_UPDATES,REQUIRE_UPDATE_BEFOREThe missing feature set has been documented, along with some quickstart examples.
Brief change log
(for example:)
ProcessTableFunctionTestHarnessVerifying this change
This change added tests and can be verified as follows:
ProcessTableFunctionTestHarnessTest.Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yes)Documentation