Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-37598][table] Support list and map state in PTFs #26396

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

twalthr
Copy link
Contributor

@twalthr twalthr commented Apr 3, 2025

What is the purpose of the change

This adds support for list and map state in PTFs via ListView and MapView.

Brief change log

  • Update ProcessTableOperator and Runner
  • Update docs and JavaDocs

Verifying this change

This change added tests and can be verified as follows:

ProcessTableFunctionTestPrograms#PROCESS_LIST_STATE
ProcessTableFunctionTestPrograms#PROCESS_MAP_STATE

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

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 3, 2025

CI report:

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

Copy link
Contributor

@snuyanzin snuyanzin left a comment

Choose a reason for hiding this comment

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

thank you for addressing feedback

final RowData value = stateHandles[i].value();
stateToFunction[i] = value;
final State stateHandle = stateHandles[i];
if (!(stateHandle instanceof ValueState)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the code would be cleaner with the if as positive and without the continue:

 if ((stateHandle instanceof ValueState)) {
           final ValueState<RowData> valueState = (ValueState<RowData>) stateHandle;
           final RowData value = valueState.value();
           valueStateToFunction[i] = value;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm following the early return principle here. I think in the end this is a matter of taste. Feel free to code it differently in your PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm following the early return principle here. I think in the end this is a matter of taste. Feel free to code it differently in your PRs.

ok no worries.

.getImplementationClass()
.map(viewClass::isAssignableFrom)
.orElse(false);
if (!isDataView) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: how about rewriting the if and returns as

 if (isDataView) {
        viewType.getChildren().forEach(DataViewUtils::checkForInvalidDataViews);
 }
return isDataView;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm following the early return principle here

Copy link
Contributor

Choose a reason for hiding this comment

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

ok no worries

valueState.clear();
} else {
final HashFunction hashCode = stateHashCode[pos];
final RecordEqualiser equals = stateEquals[pos];
Copy link
Contributor

@davidradl davidradl Apr 4, 2025

Choose a reason for hiding this comment

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

is it possible to use the equals() method on the functions to assert whether they are equal? If we are not in control as we cannot rely on the equals as they are user written, then I can see the need for a class like the Record Equaliser. I am curious on the use of RecordEqualiser, equaliser implies to me we are looking to make the functions equal - where as we are likely just looking to compare - maybe a RecordComparator might be a better name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are comparing internal data structures here. i.e. RowData. Which might be backed by memory segments. Also SQL semantics need to be considered when comparing nested data. This is why RecordEqualiser and HashFunction are code generated instances.

@davidradl
Copy link
Contributor

@twalthr thanks for addressing the feedback.

@twalthr
Copy link
Contributor Author

twalthr commented Apr 7, 2025

@flinkbot run azure

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

Successfully merging this pull request may close these issues.

4 participants