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 2020/08/30 07:09:00 UTC

[GitHub] [shardingsphere] strongduanmu opened a new pull request #7150: support mysql create, alter, drop and select view statement

strongduanmu opened a new pull request #7150:
URL: https://github.com/apache/shardingsphere/pull/7150


   Fixes #7138.
   Ref #6498.
   
   Changes proposed in this pull request:
   - support mysql create, alter, drop view statement
   - modify SchemaMetaDataLoader to support view loading
   


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

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



[GitHub] [shardingsphere] coveralls commented on pull request #7150: support mysql create, alter, drop and select view statement

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #7150:
URL: https://github.com/apache/shardingsphere/pull/7150#issuecomment-683391224


   ## Pull Request Test Coverage Report for [Build 14251](https://coveralls.io/builds/33096061)
   
   * **4** of **6**   **(66.67%)**  changed or added relevant lines in **4** files are covered.
   * **9208** unchanged lines in **1** file lost coverage.
   * Overall coverage decreased (**-0.003%**) to **35.613%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java](https://coveralls.io/builds/33096061/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-dialect%2Fshardingsphere-sql-parser-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fmysql%2Fvisitor%2Fimpl%2FMySQLDDLVisitor.java#L141) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterViewStatement.java](https://coveralls.io/builds/33096061/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fddl%2FAlterViewStatement.java#L23) | 0 | 1 | 0.0%
   <!-- | **Total:** | **4** | **6** | **66.67%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/target/generated-sources/antlr4/org/apache/shardingsphere/sql/parser/autogen/MySQLStatementParser.java](https://coveralls.io/builds/33096061/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-dialect%2Fshardingsphere-sql-parser-mysql%2Ftarget%2Fgenerated-sources%2Fantlr4%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fautogen%2FMySQLStatementParser.java#L892) | 9208 | 21.37% |
   <!-- | **Total:** | **9208** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33096061/badge)](https://coveralls.io/builds/33096061) |
   | :-- | --: |
   | Change from base [Build 14247](https://coveralls.io/builds/33095667): |  -0.003% |
   | Covered Lines: | 35536 |
   | Relevant Lines: | 99783 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


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

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



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7150: support mysql create, alter, drop and select view statement

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #7150:
URL: https://github.com/apache/shardingsphere/pull/7150#discussion_r479746324



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/schema/SchemaMetaDataLoader.java
##########
@@ -105,7 +107,7 @@ public static SchemaMetaData load(final DataSource dataSource, final int maxConn
     
     private static List<String> loadAllTableNames(final Connection connection, final String databaseType) throws SQLException {
         List<String> result = new LinkedList<>();
-        try (ResultSet resultSet = connection.getMetaData().getTables(connection.getCatalog(), JdbcUtil.getSchema(connection, databaseType), null, new String[]{TABLE_TYPE})) {
+        try (ResultSet resultSet = connection.getMetaData().getTables(connection.getCatalog(), JdbcUtil.getSchema(connection, databaseType), null, new String[]{TABLE_TYPE, VIEW_TYPE})) {

Review comment:
       Hi, why do we need to load `VIEW_TYPE `?




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

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



[GitHub] [shardingsphere] strongduanmu closed pull request #7150: support mysql create, alter, drop and select view statement and create, drop trigger statement

Posted by GitBox <gi...@apache.org>.
strongduanmu closed pull request #7150:
URL: https://github.com/apache/shardingsphere/pull/7150


   


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

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



[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #7150: support mysql create, alter, drop and select view statement

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #7150:
URL: https://github.com/apache/shardingsphere/pull/7150#discussion_r479769938



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/schema/SchemaMetaDataLoader.java
##########
@@ -105,7 +107,7 @@ public static SchemaMetaData load(final DataSource dataSource, final int maxConn
     
     private static List<String> loadAllTableNames(final Connection connection, final String databaseType) throws SQLException {
         List<String> result = new LinkedList<>();
-        try (ResultSet resultSet = connection.getMetaData().getTables(connection.getCatalog(), JdbcUtil.getSchema(connection, databaseType), null, new String[]{TABLE_TYPE})) {
+        try (ResultSet resultSet = connection.getMetaData().getTables(connection.getCatalog(), JdbcUtil.getSchema(connection, databaseType), null, new String[]{TABLE_TYPE, VIEW_TYPE})) {

Review comment:
       > Hi, why do we need to load `VIEW_TYPE `?
   
   @tristaZero The table sharding strategy will not be configured when executing the `select * from view`, so `ShardingUnconfiguredTablesRoutingEngine` will be used for routing. When the `ShardingUnconfiguredTablesRoutingEngine` performs routing, it will determine the routing result of the table based on the loaded metadata table information. In order to support the routing of the `select * from view` statement, the view information needs to be loaded in the metadata.
   
   The routing logic is as follows:
   
   ```java
   @Override
   public RouteResult route(final ShardingRule shardingRule) {
       Optional<String> dataSourceName = findDataSourceName();
       if (!dataSourceName.isPresent()) {
           throw new ShardingSphereException("Can not route tables for `%s`, please make sure the tables are in same schema.", logicTables);
       }
       RouteResult result = new RouteResult();
       List<RouteMapper> routingTables = new ArrayList<>(logicTables.size());
       for (String each : logicTables) {
           routingTables.add(new RouteMapper(each, each));
       }
       result.getRouteUnits().add(new RouteUnit(new RouteMapper(dataSourceName.get(), dataSourceName.get()), routingTables));
       return result;
   }
   
   private Optional<String> findDataSourceName() {
       for (Entry<String, SchemaMetaData> entry : unconfiguredSchemaMetaDataMap.entrySet()) {
           if (entry.getValue().getAllTableNames().containsAll(logicTables)) {
               return Optional.of(entry.getKey());
           }
       }
       return Optional.empty();
   }
   ```
   




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

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



[GitHub] [shardingsphere] coveralls edited a comment on pull request #7150: support mysql create, alter, drop and select view statement and create, drop trigger statement

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #7150:
URL: https://github.com/apache/shardingsphere/pull/7150#issuecomment-683391224


   ## Pull Request Test Coverage Report for [Build 14269](https://coveralls.io/builds/33102032)
   
   * **6** of **12**   **(50.0%)**  changed or added relevant lines in **6** files are covered.
   * **13470** unchanged lines in **4** files lost coverage.
   * Overall coverage decreased (**-0.003%**) to **35.613%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterViewStatement.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fddl%2FAlterViewStatement.java#L23) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateTriggerStatement.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fddl%2FCreateTriggerStatement.java#L23) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropTriggerStatement.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fddl%2FDropTriggerStatement.java#L23) | 0 | 1 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDDLVisitor.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-dialect%2Fshardingsphere-sql-parser-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fmysql%2Fvisitor%2Fimpl%2FMySQLDDLVisitor.java#L145) | 0 | 3 | 0.0%
   <!-- | **Total:** | **6** | **12** | **50.0%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/schema/JDBCGovernanceSchemaContexts.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-jdbc%2Fshardingsphere-jdbc-governance%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fdriver%2Fgovernance%2Finternal%2Fschema%2FJDBCGovernanceSchemaContexts.java#L64) | 1 | 64.29% |
   | [shardingsphere-proxy/shardingsphere-proxy-governance/src/main/java/org/apache/shardingsphere/proxy/governance/schema/ProxyGovernanceSchemaContexts.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-proxy%2Fshardingsphere-proxy-governance%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fproxy%2Fgovernance%2Fschema%2FProxyGovernanceSchemaContexts.java#L80) | 2 | 10.71% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/target/generated-sources/antlr4/org/apache/shardingsphere/sql/parser/autogen/SQLServerStatementParser.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-dialect%2Fshardingsphere-sql-parser-sqlserver%2Ftarget%2Fgenerated-sources%2Fantlr4%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fautogen%2FSQLServerStatementParser.java#L716) | 4059 | 29.96% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/target/generated-sources/antlr4/org/apache/shardingsphere/sql/parser/autogen/MySQLStatementParser.java](https://coveralls.io/builds/33102032/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-dialect%2Fshardingsphere-sql-parser-mysql%2Ftarget%2Fgenerated-sources%2Fantlr4%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fautogen%2FMySQLStatementParser.java#L892) | 9408 | 21.36% |
   <!-- | **Total:** | **13470** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/33102032/badge)](https://coveralls.io/builds/33102032) |
   | :-- | --: |
   | Change from base [Build 14247](https://coveralls.io/builds/33095667): |  -0.003% |
   | Covered Lines: | 35542 |
   | Relevant Lines: | 99801 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


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

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