Skip to content

Commit

Permalink
support drop table and fix create template
Browse files Browse the repository at this point in the history
  • Loading branch information
gnehil committed Oct 31, 2023
1 parent dd00f05 commit a87085b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
+ ")")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a87085b

Please sign in to comment.