You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/05 02:00:14 UTC

[GitHub] [shardingsphere] tuichenchuxin commented on a diff in pull request #17211: support pipeline generate logic table

tuichenchuxin commented on code in PR #17211:
URL: https://github.com/apache/shardingsphere/pull/17211#discussion_r865511100


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/generator/PipelineDDLGenerator.java:
##########
@@ -46,8 +56,35 @@
 @RequiredArgsConstructor
 public final class PipelineDDLGenerator {
     
+    private static final String DELIMITER = ";";
+    
+    private static final String NEWLINE = "\n";
+    
     private final ContextManager contextManager;
     
+    /**
+     * Generate logic ddl sql.
+     *
+     * @param databaseType database type
+     * @param databaseName database name
+     * @param schemaName schema name
+     * @param tableName table name
+     * @return ddl SQL
+     */
+    @SneakyThrows
+    public String generateLogicDDLSQL(final DatabaseType databaseType, final String databaseName, final String schemaName, final String tableName) {
+        ShardingSphereMetaData metaData = contextManager.getMetaDataContexts().getMetaData(databaseName);
+        String sql = generateActualDDLSQL(databaseType, schemaName, tableName, metaData);
+        String[] multiSql = sql.split(DELIMITER);
+        StringBuilder result = new StringBuilder();
+        for (final String each : multiSql) {

Review Comment:
   Thank you. Done.



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/generator/PipelineDDLGenerator.java:
##########
@@ -46,8 +56,35 @@
 @RequiredArgsConstructor
 public final class PipelineDDLGenerator {
     
+    private static final String DELIMITER = ";";
+    
+    private static final String NEWLINE = "\n";
+    
     private final ContextManager contextManager;
     
+    /**
+     * Generate logic ddl sql.
+     *
+     * @param databaseType database type
+     * @param databaseName database name
+     * @param schemaName schema name
+     * @param tableName table name
+     * @return ddl SQL
+     */
+    @SneakyThrows
+    public String generateLogicDDLSQL(final DatabaseType databaseType, final String databaseName, final String schemaName, final String tableName) {
+        ShardingSphereMetaData metaData = contextManager.getMetaDataContexts().getMetaData(databaseName);
+        String sql = generateActualDDLSQL(databaseType, schemaName, tableName, metaData);
+        String[] multiSql = sql.split(DELIMITER);

Review Comment:
   Thank you. Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org