diff --git a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/catalog/DorisCatalog.java b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/catalog/DorisCatalog.java index ae4a6f4c424b..e3b6dc78f5d9 100644 --- a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/catalog/DorisCatalog.java +++ b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/catalog/DorisCatalog.java @@ -285,7 +285,12 @@ public void createTable(TablePath tablePath, CatalogTable table, boolean ignoreI @Override public void dropTable(TablePath tablePath, boolean ignoreIfNotExists) throws TableNotExistException, CatalogException { - throw new UnsupportedOperationException(); + String query = DorisCatalogUtil.getDropTableQuery(tablePath, ignoreIfNotExists); + try (Statement stmt = conn.createStatement()) { + stmt.execute(query); + } catch (SQLException e) { + throw new CatalogException(e); + } } @Override diff --git a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisOptions.java b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisOptions.java index 293a96cb6443..3182beee2504 100644 --- a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisOptions.java +++ b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/config/DorisOptions.java @@ -230,8 +230,8 @@ public interface DorisOptions { "CREATE TABLE IF NOT EXISTS `${database}`.`${table_name}` (\n" + "${rowtype_fields}\n" + ") ENGINE=OLAP\n" - + " PRIMARY KEY (${rowtype_primary_key})\n" - + "DISTRIBUTED BY HASH (${rowtype_primary_key})" + + "UNIQUE KEY (${rowtype_primary_key})\n" + + "DISTRIBUTED BY HASH (${rowtype_primary_key})\n" + "PROPERTIES (\n" + " \"replication_num\" = \"1\" \n" + ")") diff --git a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/DorisCatalogUtil.java b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/DorisCatalogUtil.java index d99106cc5d1e..fc1884efcf36 100644 --- a/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/DorisCatalogUtil.java +++ b/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/util/DorisCatalogUtil.java @@ -87,6 +87,10 @@ public static String getDropDatabaseQuery(String database, boolean ignoreIfNotEx return "DROP DATABASE " + (ignoreIfNotExists ? "IF EXISTS " : "") + database; } + public static String getDropTableQuery(TablePath tablePath, boolean ignoreIfNotExists) { + return "DROP TABLE " + (ignoreIfNotExists ? "IF EXISTS " : "") + tablePath.getFullName(); + } + /** * @param createTableTemplate create table template * @param catalogTable catalog table