Skip to content

Commit

Permalink
[fix] Fix auto create database failed when it's name contains special…
Browse files Browse the repository at this point in the history
… symbols (apache#517)
  • Loading branch information
qg-lin authored Nov 25, 2024
1 parent 0611b93 commit 3ac63f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static String buildDatabaseExistsQuery(String database) {
}

public static String buildCreateDatabaseDDL(String database) {
return String.format(CREATE_DATABASE_DDL, database);
return String.format(CREATE_DATABASE_DDL, DorisSchemaFactory.identifier(database));
}

public static String buildModifyColumnCommentDDL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,22 @@ public void testModifyColumnTypeAndComment()
public void testCreateTableWhenDatabaseNotExists()
throws IOException, IllegalArgumentException, InterruptedException {
String databaseName = DATABASE + "_" + Integer.toUnsignedString(new Random().nextInt(), 36);
String tableName = "auto_create_database";
createTableWhenDatabaseNotExists(databaseName);
}

@Test
public void testCreateTableWhenDatabaseNotExistsAndContainsSpecialSymbol()
throws IOException, IllegalArgumentException, InterruptedException {
String databaseName =
DATABASE.replace("_", "-")
+ "_"
+ Integer.toUnsignedString(new Random().nextInt(), 36);
createTableWhenDatabaseNotExists(databaseName);
}

public void createTableWhenDatabaseNotExists(String databaseName)
throws IOException, IllegalArgumentException, InterruptedException {
String tableName = "auto_create_database";
TableSchema tableSchema = new TableSchema();
tableSchema.setDatabase(databaseName);
tableSchema.setTable(tableName);
Expand All @@ -240,6 +254,7 @@ public void testCreateTableWhenDatabaseNotExists()
Map<String, String> tableProperties = new HashMap<>();
tableProperties.put("replication_num", "1");
tableSchema.setProperties(tableProperties);

schemaChangeManager.createTable(tableSchema);

Thread.sleep(3_000);
Expand Down

0 comments on commit 3ac63f2

Please sign in to comment.