From e8cef17a6fafe25d12ee338ce0fe0c86827e9c0d Mon Sep 17 00:00:00 2001 From: IlyaTsoi <45252974+IlyaTsoi@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:49:55 +0300 Subject: [PATCH] Get last element as a table name from a topic name It would be better if it didn't depend on the hard-coded .. template --- .../clickhouse/sink/connector/common/Utils.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sink-connector/src/main/java/com/altinity/clickhouse/sink/connector/common/Utils.java b/sink-connector/src/main/java/com/altinity/clickhouse/sink/connector/common/Utils.java index 079961470..5418b76b5 100644 --- a/sink-connector/src/main/java/com/altinity/clickhouse/sink/connector/common/Utils.java +++ b/sink-connector/src/main/java/com/altinity/clickhouse/sink/connector/common/Utils.java @@ -88,13 +88,9 @@ public static Map 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; } @@ -108,4 +104,4 @@ public static boolean isValidTable(String tableName) { return true; } -} \ No newline at end of file +}