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/08/17 12:12:44 UTC

[GitHub] [shardingsphere] azexcy opened a new pull request, #20245: Improve DDL genereate method at migration prepare

azexcy opened a new pull request, #20245:
URL: https://github.com/apache/shardingsphere/pull/20245

   Revise #20207
   
   Changes proposed in this pull request:
   -  Improve DDL generate.
   


-- 
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


[GitHub] [shardingsphere] sandynz commented on a diff in pull request #20245: Improve DDL genereate method at migration prepare

Posted by GitBox <gi...@apache.org>.
sandynz commented on code in PR #20245:
URL: https://github.com/apache/shardingsphere/pull/20245#discussion_r947870787


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/generator/PipelineDDLGenerator.java:
##########
@@ -132,39 +134,38 @@ private Optional<String> decorate(final DatabaseType databaseType, final String
     }
     
     private Collection<String> generateActualDDLSQL(final DatabaseType databaseType, final String schemaName, final String actualTable, final DataSource dataSource) throws SQLException {
-        return CreateTableSQLGeneratorFactory.findInstance(databaseType).orElseThrow(() -> new ShardingSphereException("Failed to get dialect ddl sql generator"))
+        return CreateTableSQLGeneratorFactory.findInstance(databaseType).orElseThrow(() -> new ServiceProviderNotFoundException(DatabaseType.class))
                 .generate(actualTable, schemaName, dataSource);
     }

Review Comment:
   `new ServiceProviderNotFoundException(DatabaseType.class))` could be improved, seems `new ServiceProviderNotFoundException(CreateTableSQLGenerator.class, databaseType))` could be used.
   



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/prepare/datasource/MySQLDataSourcePreparer.java:
##########
@@ -58,14 +61,14 @@ private List<String> getCreateTableSQL(final PrepareTargetTablesParameter parame
         PipelineDDLGenerator generator = new PipelineDDLGenerator();
         ShardingSphereMetaData metaData = PipelineContext.getContextManager().getMetaDataContexts().getMetaData();
         ShardingSphereDatabase sphereDatabase = metaData.getDatabases().get(parameter.getDatabaseName());
-        ShardingSphereSQLParserEngine sqlParserEngine =
-                metaData.getGlobalRuleMetaData().getSingleRule(SQLParserRule.class)
-                        .getSQLParserEngine(sphereDatabase.getProtocolType().getType());
+        ShardingSphereSQLParserEngine sqlParserEngine = metaData.getGlobalRuleMetaData().getSingleRule(SQLParserRule.class).getSQLParserEngine(sphereDatabase.getProtocolType().getType());
         List<String> result = new LinkedList<>();
         for (JobDataNodeEntry each : parameter.getTablesFirstDataNodes().getEntries()) {
             String schemaName = parameter.getTableNameSchemaNameMapping().getSchemaName(each.getLogicTableName());
             String dataSourceName = each.getDataNodes().get(0).getDataSourceName();
-            result.add(generator.generateLogicDDLSQL(sphereDatabase, dataSourceName, schemaName, each.getLogicTableName(),
+            DataSource dataSource = sphereDatabase.getResource().getDataSources().get(dataSourceName);
+            DatabaseType databaseType = DatabaseTypeEngine.getDatabaseType(Collections.singletonList(dataSource));

Review Comment:
   Could we extract `sphereDatabase` to job preparer?



-- 
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


[GitHub] [shardingsphere] codecov-commenter commented on pull request #20245: Improve DDL genereate method at migration prepare

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #20245:
URL: https://github.com/apache/shardingsphere/pull/20245#issuecomment-1219024467

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/20245?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20245](https://codecov.io/gh/apache/shardingsphere/pull/20245?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2a17a36) into [master](https://codecov.io/gh/apache/shardingsphere/commit/ae4afbd602aa606819d3d3cf1277b6e643bf189c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ae4afbd) will **increase** coverage by `0.01%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #20245      +/-   ##
   ============================================
   + Coverage     60.86%   60.87%   +0.01%     
   - Complexity     2421     2422       +1     
   ============================================
     Files          3873     3876       +3     
     Lines         54673    54690      +17     
     Branches       9306     9310       +4     
   ============================================
   + Hits          33275    33295      +20     
   + Misses        18545    18542       -3     
     Partials       2853     2853              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/20245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../core/metadata/generator/PipelineDDLGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2NvcmUvbWV0YWRhdGEvZ2VuZXJhdG9yL1BpcGVsaW5lRERMR2VuZXJhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...prepare/datasource/AbstractDataSourcePreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2NvcmUvcHJlcGFyZS9kYXRhc291cmNlL0Fic3RyYWN0RGF0YVNvdXJjZVByZXBhcmVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...epare/datasource/PrepareTargetTablesParameter.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL2NvcmUvcHJlcGFyZS9kYXRhc291cmNlL1ByZXBhcmVUYXJnZXRUYWJsZXNQYXJhbWV0ZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...eline/scenario/migration/MigrationJobPreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL3NjZW5hcmlvL21pZ3JhdGlvbi9NaWdyYXRpb25Kb2JQcmVwYXJlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ql/prepare/datasource/MySQLDataSourcePreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1kaWFsZWN0L3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUtbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvbXlzcWwvcHJlcGFyZS9kYXRhc291cmNlL015U1FMRGF0YVNvdXJjZVByZXBhcmVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...repare/datasource/OpenGaussDataSourcePreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1kaWFsZWN0L3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUtb3BlbmdhdXNzL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL29wZW5nYXVzcy9wcmVwYXJlL2RhdGFzb3VyY2UvT3BlbkdhdXNzRGF0YVNvdXJjZVByZXBhcmVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...epare/datasource/PostgreSQLDataSourcePreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1kaWFsZWN0L3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9wb3N0Z3Jlc3FsL3ByZXBhcmUvZGF0YXNvdXJjZS9Qb3N0Z3JlU1FMRGF0YVNvdXJjZVByZXBhcmVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...l/parser/core/database/visitor/SQLVisitorRule.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9jb3JlL2RhdGFiYXNlL3Zpc2l0b3IvU1FMVmlzaXRvclJ1bGUuamF2YQ==) | `100.00% <0.00%> (ø)` | |
   | [...ter/segment/expression/impl/FunctionConverter.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZmVkZXJhdGlvbi9zaGFyZGluZ3NwaGVyZS1pbmZyYS1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvZmVkZXJhdGlvbi9vcHRpbWl6ZXIvY29udmVydGVyL3NlZ21lbnQvZXhwcmVzc2lvbi9pbXBsL0Z1bmN0aW9uQ29udmVydGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...rojection/impl/AggregationProjectionConverter.java](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtZmVkZXJhdGlvbi9zaGFyZGluZ3NwaGVyZS1pbmZyYS1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvZmVkZXJhdGlvbi9vcHRpbWl6ZXIvY29udmVydGVyL3NlZ21lbnQvcHJvamVjdGlvbi9pbXBsL0FnZ3JlZ2F0aW9uUHJvamVjdGlvbkNvbnZlcnRlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | ... and [22 more](https://codecov.io/gh/apache/shardingsphere/pull/20245/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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


[GitHub] [shardingsphere] sandynz merged pull request #20245: Improve DDL genereate method at migration prepare

Posted by GitBox <gi...@apache.org>.
sandynz merged PR #20245:
URL: https://github.com/apache/shardingsphere/pull/20245


-- 
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