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/06/02 12:13:11 UTC

[GitHub] [shardingsphere] sym-163 opened a new issue #5892: subquery as a column can not work

sym-163 opened a new issue #5892:
URL: https://github.com/apache/shardingsphere/issues/5892


   ### subquery as a column can not work,for example:
   ```sql
   SELECT
   	company_id,
   	site_id,
   	site_name,
   	( SELECT status FROM jf_company WHERE company_id = st_site.company_id ) AS 
           company_status 
   FROM
   	st_site 
   WHERE
   	 is_delete = 0;
   ```
   but the result not contain company_status column.
   So i change the code and add these code in this file:
   ```shell
   apache-shardingsphere-4.1.0-src-release\shardingsphere-sql-parser\shardingsphere-sql-parser-binder\src\main\java\org\apache\shardingsphere\sql\parser\binder\segment\select\projection\engine\ProjectionEngine.java
   ```
   ```java
   // todo subquery
           if (projectionSegment instanceof SubqueryProjectionSegment) {
               SubquerySegment subquery = ((SubqueryProjectionSegment) projectionSegment).getSubquery();
               Collection<ProjectionSegment> projections = subquery.getSelect().getProjections().getProjections();
               Collection<SimpleTableSegment> simpleTableSegments = subquery.getSelect().getSimpleTableSegments();
   //            String subSql = sql.substring(subquery.getStartIndex(), subquery.getStopIndex());
               for (ProjectionSegment ps:projections) {
                   // sub sql 截取
                   return createProjection(sql, simpleTableSegments, ps);
               }
           }
   ```
   **it can work right,However has better way?**


----------------------------------------------------------------
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] sym-163 commented on issue #5892: subquery as a column can not work

Posted by GitBox <gi...@apache.org>.
sym-163 commented on issue #5892:
URL: https://github.com/apache/shardingsphere/issues/5892#issuecomment-641740907


   > subquery issue is pending for now, will do it on 5.x
   
   好的好的,我就是不太确定,我加的那断代码正不正确,虽然能查询到数据。
   还是就是使用代理与不使用代码,性能上相差近3倍?


----------------------------------------------------------------
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 commented on issue #5892: subquery as a column can not work

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


   subquery issue is pending for now, will do it no 5.x


----------------------------------------------------------------
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 commented on issue #5892: subquery as a column can not work

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


   The `5.0.0-beta` version supports federation engine which can process subquery, please try it, thank you.


-- 
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] terrymanu closed issue #5892: subquery as a column can not work

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


   


-- 
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] terrymanu edited a comment on issue #5892: subquery as a column can not work

Posted by GitBox <gi...@apache.org>.
terrymanu edited a comment on issue #5892:
URL: https://github.com/apache/shardingsphere/issues/5892#issuecomment-641704507


   subquery issue is pending for now, will do it on 5.x


----------------------------------------------------------------
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] sym-163 edited a comment on issue #5892: subquery as a column can not work

Posted by GitBox <gi...@apache.org>.
sym-163 edited a comment on issue #5892:
URL: https://github.com/apache/shardingsphere/issues/5892#issuecomment-641740907


   > subquery issue is pending for now, will do it on 5.x
   
   好的好的,我就是不太确定,我加的那断代码正不正确,虽然能查询到数据。
   还是就是使用Sharding-Proxy后,性能上相差近3倍?


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