huanghao495430759 commented on issue #8605:
URL: https://github.com/apache/shardingsphere/issues/8605#issuecomment-760812843


   > when I used @iblilife's sql:
   > `SELECT a.*, b.id FROM table_a a LEFT JOIN table_b b ON (a.id = b.id)`;
   > and shardingsphere-5.0.0-RC1-SNAPSHOT have the same proplem.
   > 
   > when shardingsphere create ShardingSpherePreparedStatement
   > I think the bug may be at SchemaBuilder.java line 70:
   > 
![image](https://user-images.githubusercontent.com/34728144/104438647-2b69ad00-55cb-11eb-9750-964239b63f6e.png)
   > 
   > when load unconfig tables MeataData,it only init TableMetaData(), but 
doesn't load table columns,
   > so when doQuery in :
   > 
`->org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement#execute
 
->org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement#createExecutionContext
 
->org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement#createLogicSQL
 
->org.apache.shardingsphere.infra.binder.SQLStatementContextFactory#newInstance 
->new SelectStatementContext 
->org.apache.shardingsphere.infra.binder.segment.select.projection.engine.ProjectionsContextEngine#createProjectionsContext
 
->org.apache.shardingsphere.infra.binder.segment.select.projection.engine.ProjectionsContextEngine#getProjections
 
->org.apache.shardingsphere.infra.binder.segment.select.projection.engine.ProjectionEngine#createProjection(final
 Collection<SimpleTableSegment> tableSegments, final ShorthandProjectionSegment 
projectionSegment) 
->org.apache.shardingsphere.infra.binder.segment.select.projection.engine.ProjectionEngine#getShorthandColumns`
   > when get ShorthandColumns, table columns is empty
   > 
![image](https://user-images.githubusercontent.com/34728144/104438411-efcee300-55ca-11eb-9433-925d656fc4b5.png)
   > so after ShardingSpherePreparedStatement#execute,
   > and handle resultSet
   > 
![image](https://user-images.githubusercontent.com/34728144/104438860-7257a280-55cb-11eb-9e63-938cc9d59004.png)
   > 
`->org.apache.ibatis.executor.resultset.DefaultResultSetHandler#handleResultSets
 
->org.apache.ibatis.executor.resultset.DefaultResultSetHandler#getFirstResultSet
 ->org.apache.ibatis.executor.resultset.ResultSetWrapper#ResultSetWrapper() 
->org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSetMetaData#getColumnCount
 
->org.apache.shardingsphere.infra.binder.segment.select.projection.ProjectionsContext#getExpandProjections`
   > 
![image](https://user-images.githubusercontent.com/34728144/104439228-d9755700-55cb-11eb-985e-20642a7e5a6c.png)
   > 
![image](https://user-images.githubusercontent.com/34728144/104439686-5a345300-55cc-11eb-872c-43856b826311.png)
   > 
   > in this code, ShorthandProjection actual columns is empty,so after 
getExpandProjections(), columnCount is only 1
   > 
![image](https://user-images.githubusercontent.com/34728144/104439787-7c2dd580-55cc-11eb-99c9-ca2a7525045d.png)
   > 
   > 
![image](https://user-images.githubusercontent.com/34728144/104440276-1b52cd00-55cd-11eb-96d7-6951241b3559.png)
   > and ResultSet only get one column。
   > 
   > so I think bug maybe at
   > 
`->org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilder#appendRemainTables
 line 70`
   > 
![image](https://user-images.githubusercontent.com/34728144/104441089-32de8580-55ce-11eb-82d2-7e73196a7dbd.png)
   > shardingsphere must be load remain table MetaData when System start.
   
   @strongduanmu
   @tristaZero 


----------------------------------------------------------------
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:
[email protected]


Reply via email to