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

[Fix][StarRocks] Fix NPE when upstream catalogtable table path only have table name part #6540

Merged
merged 4 commits into from
Mar 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ public TableSink createSink(TableSinkFactoryContext context) {
String sinkDatabaseName = sinkConfig.getDatabase();
String sinkTableName = sinkConfig.getTable();
// to replace
String finalDatabaseName =
sinkDatabaseName.replace(REPLACE_DATABASE_NAME_KEY, sourceDatabaseName);
if (StringUtils.isNotBlank(sourceDatabaseName)) {
sinkDatabaseName =
sinkDatabaseName.replace(REPLACE_DATABASE_NAME_KEY, sourceDatabaseName);
}
Copy link
Member

Choose a reason for hiding this comment

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

I prefer when source database name is null, we can treat it as empty string.

Suggested change
if (StringUtils.isNotBlank(sourceDatabaseName)) {
sinkDatabaseName =
sinkDatabaseName.replace(REPLACE_DATABASE_NAME_KEY, sourceDatabaseName);
}
sinkDatabaseName = sinkDatabaseName.replace(REPLACE_DATABASE_NAME_KEY, sourceDatabaseName != null ? sourceDatabaseName: "");

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

String finalTableName = this.replaceFullTableName(sinkTableName, tableId);
// rebuild TableIdentifier and catalogTable
TableIdentifier newTableId =
TableIdentifier.of(
tableId.getCatalogName(), finalDatabaseName, null, finalTableName);
tableId.getCatalogName(), sinkDatabaseName, null, finalTableName);
catalogTable =
CatalogTable.of(
newTableId,
Expand All @@ -107,7 +109,7 @@ public TableSink createSink(TableSinkFactoryContext context) {
CatalogTable finalCatalogTable = catalogTable;
// reset
sinkConfig.setTable(finalTableName);
sinkConfig.setDatabase(finalDatabaseName);
sinkConfig.setDatabase(sinkDatabaseName);
return () -> new StarRocksSink(sinkConfig, finalCatalogTable, context.getOptions());
}

Expand Down
Loading