Skip to content

Commit

Permalink
Get last element as a table name from a topic name
Browse files Browse the repository at this point in the history
It would be better if it didn't depend on the hard-coded <server>.<database>.<table> template
  • Loading branch information
IlyaTsoi authored Oct 24, 2023
1 parent 4465815 commit e8cef17
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ public static Map<String, String> parseTopicToTableMap(String input) throws Exce
public static String getTableNameFromTopic(String topicName) {
String tableName = null;


// topic names is of the following format.
// hostname.dbName.tableName
// get last element after deviding topicName by "." as tableName
String[] splitName = topicName.split("\\.");
if(splitName.length == 3) {
tableName = splitName[2];
}
tableName = splitName[splitName.length - 1];

return tableName;
}
Expand All @@ -108,4 +104,4 @@ public static boolean isValidTable(String tableName) {
return true;
}

}
}

0 comments on commit e8cef17

Please sign in to comment.