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 2021/05/06 12:38:38 UTC

[GitHub] [shardingsphere] RookieMember opened a new issue #10258: Broadcast table SQL write * does not work properly

RookieMember opened a new issue #10258:
URL: https://github.com/apache/shardingsphere/issues/10258


   ### Which version of ShardingSphere did you use?
   4.1.1
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   select * from t_address
   All results should be returned
   ### Actual behavior
   All elements in the returned collection are null
   ![image](https://user-images.githubusercontent.com/43982372/117297068-593f6e00-aea8-11eb-98d0-ab38ecf15b3b.png)
   
   ### Reason analyze (If you can)
   I read the source code, issued the following code:
   org.apache.shardingsphere.sql.parser.binder.segment.select.projection.engine.ProjectionEngine#getUnqualifiedShorthandColumns
   ```
   private Collection<ColumnProjection> getUnqualifiedShorthandColumns(final Collection<SimpleTableSegment> tables) {
           Collection<ColumnProjection> result = new LinkedList<>();
           for (SimpleTableSegment each : tables) {
               result.addAll(schemaMetaData.getAllColumnNames(
                       each.getTableName().getIdentifier().getValue()).stream().map(columnName -> new ColumnProjection(null, columnName, null)).collect(Collectors.toList()));
           }
           return result;
       }
   ```
   I guess schemaMetaData does not contain a broadcast table, so the column for the broadcast table cannot be obtained。
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   ```
   <dependency>
   	<groupId>org.mybatis.spring.boot</groupId>
   	<artifactId>mybatis-spring-boot-starter</artifactId>
   	<version>2.0.1</version>
   </dependency>
   <dependency>
   	<groupId>org.apache.shardingsphere</groupId>
   	<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
   	<version>4.1.1</version>
   </dependency>
   ```
   ```
   CREATE TABLE `t_address` (
     `address_id` bigint(20) NOT NULL,
     `address_name` varchar(100) NOT NULL,
     PRIMARY KEY (`address_id`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
   ```
   ```
   @Mapper
   public interface AddressMapper {
       
       List<Address> selectAll() throws SQLException;
   }
   ```
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
   <mapper namespace="com.wkp.shardingjdbc.mapper.AddressMapper">
       <resultMap id="BaseResultMap" type="com.wkp.shardingjdbc.entity.Address">
           <id column="address_id" jdbcType="INTEGER" property="addressId"/>
           <result column="address_name" jdbcType="VARCHAR" property="addressName"/>
       </resultMap>
       <sql id="Base_Column_List">address_id, address_name</sql>
   
       <select id="selectAll" resultMap="BaseResultMap">
           select * from t_address
       </select>
   <!--
       <select id="selectAll" resultMap="BaseResultMap">
           select <include refid="Base_Column_List"/> from t_address
       </select>
   -->
   </mapper>
   ```
   `spring.shardingsphere.sharding.broadcast-tables=t_address
   `
   
   1:When I use "select * from t_address",All elements in the returned collection are null
   2:When I use "select address_id, address_name from t_address",Returns the correct result set
   
   


-- 
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] avalon5666 commented on issue #10258: Broadcast table SQL write "select * from t" does not work properly

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10258:
URL: https://github.com/apache/shardingsphere/issues/10258#issuecomment-833974054


   I can't reproduce it. Can you push the demo on github?


-- 
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] RookieMember commented on issue #10258: Broadcast table SQL write "select * from t" does not work properly

Posted by GitBox <gi...@apache.org>.
RookieMember commented on issue #10258:
URL: https://github.com/apache/shardingsphere/issues/10258#issuecomment-834104325


   > I can't reproduce it. Can you push the demo on github?
   
   demo GitHub:https://github.com/RookieMember/shardingsphere-demo/tree/master/shardingjdbc-demo
   
   https://github.com/RookieMember/shardingsphere-demo/blob/master/shardingjdbc-demo/src/main/java/com/wkp/shardingjdbc/controller/AddressController.java#selectAll
      ```
   @GetMapping("/select_all_address")
       public List<Address> selectAll() throws SQLException {
           return addressServiceImpl.selectAll();
       }
   ```
   I used mybatis's XML and annotation methods to test, and the results are the same. There is a problem when using "select * from t_address".
   
   
   


-- 
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] avalon5666 commented on issue #10258: Broadcast table SQL write "select * from t" does not work properly

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10258:
URL: https://github.com/apache/shardingsphere/issues/10258#issuecomment-834140200


   Try compile from master bracnh, Fix at #9076


-- 
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] terrymanu closed issue #10258: Broadcast table SQL write "select * from t" does not work properly

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #10258:
URL: https://github.com/apache/shardingsphere/issues/10258


   


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