This is an automated email from the ASF dual-hosted git repository.

diwu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-flink-connector.git


The following commit(s) were added to refs/heads/master by this push:
     new 3ac63f2e [fix] Fix auto create database failed when it's name contains 
special symbols (#517)
3ac63f2e is described below

commit 3ac63f2e9379e27a390771faf67a01111a29add7
Author: North Lin <37775475+qg-...@users.noreply.github.com>
AuthorDate: Mon Nov 25 10:47:52 2024 +0800

    [fix] Fix auto create database failed when it's name contains special 
symbols (#517)
---
 .../doris/flink/sink/schema/SchemaChangeHelper.java     |  2 +-
 .../doris/flink/sink/schema/SchemaManagerITCase.java    | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/schema/SchemaChangeHelper.java
 
b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/schema/SchemaChangeHelper.java
index d0630b03..b772ec3d 100644
--- 
a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/schema/SchemaChangeHelper.java
+++ 
b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/schema/SchemaChangeHelper.java
@@ -150,7 +150,7 @@ public class SchemaChangeHelper {
     }
 
     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(
diff --git 
a/flink-doris-connector/src/test/java/org/apache/doris/flink/sink/schema/SchemaManagerITCase.java
 
b/flink-doris-connector/src/test/java/org/apache/doris/flink/sink/schema/SchemaManagerITCase.java
index c4f7f282..b3cc0abc 100644
--- 
a/flink-doris-connector/src/test/java/org/apache/doris/flink/sink/schema/SchemaManagerITCase.java
+++ 
b/flink-doris-connector/src/test/java/org/apache/doris/flink/sink/schema/SchemaManagerITCase.java
@@ -226,8 +226,22 @@ public class SchemaManagerITCase extends 
AbstractITCaseService {
     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);
@@ -240,6 +254,7 @@ public class SchemaManagerITCase extends 
AbstractITCaseService {
         Map<String, String> tableProperties = new HashMap<>();
         tableProperties.put("replication_num", "1");
         tableSchema.setProperties(tableProperties);
+
         schemaChangeManager.createTable(tableSchema);
 
         Thread.sleep(3_000);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to