Skip to content

Conversation

@icchux
Copy link
Contributor

@icchux icchux commented Dec 31, 2023

Add the mapper parameter and prioritize using the Route rule for replacement. If a table does not specify a table rule, use the database rule for replacement

replaceIdentifier = String.join(".", schemaRoute.f1, replaceTableName);
}

return recreateChangeEvent(changeEvent, TableId.parse(replaceIdentifier));
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use new TableId(tableId.getSchemaName(), schemaRoute.f1, replaceTableName) to simplify the join and parse code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get. i will process it,but there only hava TableId.tableId() function can be use,it is ok?

// then schema route
        for (Tuple4<String, String, String, String> schemaRoute : schemaRoutes) {
            if (schemaRoute.f0.equals(tableId.getSchemaName())) {
                // database routing, table add prefix and suffix mapping
                TableId replaceBy;
                String replaceTableName =
                        Optional.ofNullable(schemaRoute.f2).orElse("")
                                + tableId.getTableName()
                                + Optional.ofNullable(schemaRoute.f3).orElse("");
                if (tableId.getNamespace() != null) {
                    replaceBy = TableId.tableId(tableId.getNamespace(),schemaRoute.f1, replaceTableName);
                } else {
                    replaceBy = TableId.tableId(schemaRoute.f1, replaceTableName);
                }

                return recreateChangeEvent(changeEvent, replaceBy);
            }
        }

Copy link
Contributor

@lvyanquan lvyanquan Jan 2, 2024

Choose a reason for hiding this comment

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

but there only hava TableId.tableId() function can be use,it is ok?

Yeah, This will be more concise.

@lvyanquan
Copy link
Contributor

lvyanquan commented Jan 2, 2024

There is another pr #2908 provides a new idea, We can use placeholders to represent the original table name and database name, It‘s useful to add suffixes and suffixes while keeping parameters as before.

@leonardBang
Copy link
Contributor

Closed by #3428

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.

3 participants