Skip to content

[FLINK-40230][table] StringToBinary and RawToBinary cast rules might generate runtime code with useless array copy#28814

Open
snuyanzin wants to merge 1 commit into
apache:masterfrom
snuyanzin:flink40230
Open

[FLINK-40230][table] StringToBinary and RawToBinary cast rules might generate runtime code with useless array copy#28814
snuyanzin wants to merge 1 commit into
apache:masterfrom
snuyanzin:flink40230

Conversation

@snuyanzin

@snuyanzin snuyanzin commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

In case of same size it generates code to copy array while in fact there is no need for that
The PR makes the generation more optimal

Brief change log

rules

Verifying this change

existing cast 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): (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? (no)
  • If yes, how is the feature documented? (not applicable)

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

…ght generate runtime code with useless array copy
@flinkbot

flinkbot commented Jul 24, 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

@raminqaf raminqaf left a comment

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.

Thanks for this fix! Left some comments

}
},
arrayLength(byteArrayTerm)
+ (couldPad ? " == " : " <= ")

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.

Should we find a common class for this logic?

couldPad ? " == " : " <= "

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.

Can we add some tests in CastRulesTest?

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.

It is already covered by tens of tests exactly for these rules

.toString();
} else {
final int targetLength = LogicalTypeChecks.getLength(targetLogicalType);
final boolean couldPad = couldPad(targetLogicalType, targetLength);

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 move the computation of couldPad lower in the condition

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants