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-35647][route] Allow symbol replacement to simplify routing rules #3428

Merged
merged 6 commits into from
Jul 12, 2024

Conversation

yuxiqian
Copy link
Contributor

@yuxiqian yuxiqian commented Jun 19, 2024

This closes FLINK-35647, inspired by #2908 and #2947. Credit goes to @icchux and @WholeWorld-Timothy.


Currently, we must provide explicit sink-table in pipeline route rules, which means if we'd like to route all tables in specific database and change names in pattern, there's no choice but write all rules separately, which is a chore.

This PR allows specifying a special "replacement symbol" to resemble original table name in route rules like this:

route:
  - source-table: db.\.*
    sink-table: new_db.<>
    replace-symbol: <>

Now, <> will be replaced by upstream table name, so any tables like db.tableX will be routed to new_db.tableX automatically.

docs/content/docs/core-concept/route.md Outdated Show resolved Hide resolved
private TableId resolveReplacement(
TableId originalTable, Tuple3<Selectors, String, String> route) {
if (route.f2 != null) {
return TableId.parse(route.f1.replace(route.f2, originalTable.getTableName()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use Map<TableId, TableId> to reduce this replace and parse operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, used LoadingCache to store table mapping relations. As for previously discussed hashCode caching optimization, I'll open another PR to address it.

Copy link
Contributor

@lvyanquan lvyanquan left a comment

Choose a reason for hiding this comment

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

LGTM, thank all contributors.

Copy link
Contributor

@leonardBang leonardBang left a comment

Choose a reason for hiding this comment

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

Thanks @yuxiqian, @icchux and @WholeWorld-Timothy for the contribution, LGTM

@leonardBang
Copy link
Contributor

@icchux and @WholeWorld-Timothy I've added you as co-authors in this PR, and thus I closed #2908 and #2947.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli common composer docs Improvements or additions to documentation e2e-tests runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants