You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "dabingRyan (via GitHub)" <gi...@apache.org> on 2023/02/17 04:01:54 UTC

[GitHub] [shardingsphere] dabingRyan opened a new issue, #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

dabingRyan opened a new issue, #24207:
URL: https://github.com/apache/shardingsphere/issues/24207

   ## Bug Report
   java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx].
   
   ### Which version of ShardingSphere did you use?
   <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
               <version>5.2.0</version>
           </dependency>
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   shardingsphere-jdbc Read/Write Splitting
   
   ### Expected behavior
   
   
   java:
   private Collection<ColumnProjection> getColumnProjections(final Collection<Projection> projections) {
           Collection<ColumnProjection> result = new LinkedList<>();
           for (Projection each : projections) {
               if (each instanceof ColumnProjection) {
                   result.add((ColumnProjection) each);
               }
               if (each instanceof ShorthandProjection) {
                   result.addAll(((ShorthandProjection) each).getActualColumns().values());
               }
           }
           return result;
       }
   
   in this projections ,there has some ExpressionProjection, but not add to result.   
   sql:
   select ifnull(sell_price,0) productPrice from product where id=1;    
   
   ifnull(sell_price) productPrice is a ExpressionProjection
   ### Actual behavior
   
   


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

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


Re: [I] java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx] [shardingsphere]

Posted by "zxk1111 (via GitHub)" <gi...@apache.org>.
zxk1111 commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-2185428616

   i has the same error,like select t.*  from (select s.field_1,if(s.field_2 is null,1,2) as field_2 from sub s)t  will display this error because of t.*,
   if like select t.field_1,t.field_2 will success,
   
   error msg:
   java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[field_2]
   
   related version:
   <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
               <version>5.1.1</version>
   </dependency>
   <dependency>
               <groupId>com.alibaba</groupId>
               <artifactId>druid-spring-boot-starter</artifactId>
               <version>1.2.20</version>
   </dependency>


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


Re: [I] java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx] [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu closed issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]
URL: https://github.com/apache/shardingsphere/issues/24207


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


Re: [I] java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx] [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-2024283207

   Duplicate with #24207


-- 
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] fangs95 commented on issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

Posted by "fangs95 (via GitHub)" <gi...@apache.org>.
fangs95 commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-1579047451

   This problem is due to the use of expressions in the select clause. It should be because this is a framework for data shard that the expressions in select are disabled.
   org.apache.shardingsphere.infra.binder.segment.select.projection.engine.ProjectionEngine#getColumnProjections
   ```java
       private Collection<ColumnProjection> getColumnProjections(final Collection<Projection> projections) {
           Collection<ColumnProjection> result = new LinkedList<>();
           for (Projection each : projections) {
               if (each instanceof ColumnProjection) {
                   result.add((ColumnProjection) each);
               }
               if (each instanceof ShorthandProjection) {
                   result.addAll(((ShorthandProjection) each).getActualColumns().values());
               }
           }
           return result;
       }
   ```
   This code will filter out the ExpressionProjection.
   
   Because I only use read-write separation, I override this method in my own project.
   ```java
       private Collection<ColumnProjection> getColumnProjections(final Collection<Projection> projections) {
           Collection<ColumnProjection> result = new LinkedList<>();
           int mockSeq = 0;
           for (Projection each : projections) {
               if (each instanceof ColumnProjection) {
                   result.add((ColumnProjection) each);
               }
               if (each instanceof ExpressionProjection) {
                   ExpressionProjection expressionProjection = (ExpressionProjection) each;
                   ColumnProjection projection = new ColumnProjection(null, "mock" + mockSeq++, expressionProjection.getAlias().get());
                   result.add(projection);
               }
               if (each instanceof ShorthandProjection) {
                   result.addAll(((ShorthandProjection) each).getActualColumns().values());
               }
           }
           return result;
       }
   ```
   I just don't know if changing this will cause other problems


-- 
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] dabingRyan commented on issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

Posted by "dabingRyan (via GitHub)" <gi...@apache.org>.
dabingRyan commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-1448443745

   my  SQL statements is:
   `
   select *
   from (select a.CLIENT                      client,
                a.PRO_SITE                    storeId,
                f.STO_NAME                    stoName,
                a.PRO_SELF_CODE               proCode,
                a.PRO_DEPICT                  proDepict,
                a.PRO_PYM                     proPym,
                IFNULL(SUM(b.GSSB_QTY), 0) AS inventoryQty
         from GAIA_PRODUCT_BUSINESS a
                  LEFT JOIN GAIA_SD_STOCK_BATCH b on a.PRODUCT_ID = b.PRODUCT_ID
         WHERE a.CLIENT = 'ABCD') aa;
   `
   there is an exception 
   `Can not get index from column label `inventoryQty`.; nested exception is java.sql.SQLFeatureNotSupportedException: Can not get index from column label `inventoryQty`.>
   org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'inventoryQty' from result set.  Cause: java.sql.SQLFeatureNotSupportedException: Can not get index from column label `inventoryQty`.
   ; Can not get index from column label `inventoryQty`.; nested exception is java.sql.SQLFeatureNotSupportedException: Can not get index from column label `inventoryQty`.
   	at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:96)
   	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
   	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79)
   	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439)
   	at com.sun.proxy.$Proxy110.selectList(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
   	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
   	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
   	at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
   	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
   	at com.sun.proxy.$Proxy174.findListForHisClinicZhongXiPage(Unknown Source)
   	at com.gov.external.modules.product.service.impl.ProductServiceImpl.searchClinicPage(ProductServiceImpl.java:338)
   	at com.gov.external.modules.product.service.impl.ProductServiceImpl$$FastClassBySpringCGLIB$$8fc4ea9f.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)`
   
   But when I delete the outermost alias aa, it's ok!
   like this :
   `select a.CLIENT                      client,
                a.PRO_SITE                    storeId,
                f.STO_NAME                    stoName,
                a.PRO_SELF_CODE               proCode,
                a.PRO_DEPICT                  proDepict,
                a.PRO_PYM                     proPym,
                IFNULL(SUM(b.GSSB_QTY), 0) AS inventoryQty
         from GAIA_PRODUCT_BUSINESS a
                  LEFT JOIN GAIA_SD_STOCK_BATCH b on a.PRODUCT_ID = b.PRODUCT_ID
         WHERE a.CLIENT = 'ABCD'`


-- 
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] peachyy commented on issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

Posted by "peachyy (via GitHub)" <gi...@apache.org>.
peachyy commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-1551152589

   I had the same problem 。version shardingsphere 5.1.1 
   at sql column  subquery `(SELECT count(1) FROM con_article_likes WHERE user_id = ? AND art_id = t2.art_id AND con_article_likes.tenant_id = '1') AS artIsLike`  current is  SubqueryProjection
   
   ---------screenshot-----------
   
   ![1684319538686](https://github.com/apache/shardingsphere/assets/8952611/5b6ce49b-9cd1-4e43-9f46-66958938d9ad)
   
   
   ----------------sql -------------
   
   `
   Actual SQL: s1 :::  SELECT * FROM (SELECT t1.link_id AS linkId, t1.type AS rType, t2.art_id, t2.type AS artType, t2.keyword AS artKeyword, t2.title AS artTitle, t2.summary AS artSummary, t2.user_id AS artUserId, t2.content AS artConetent, t2.share_count AS artShareCount, (t2.views_count_base) AS artViewsCount, t2.comment_count AS artCommentcount, (t2.likes_count_base) AS artLikesCount, t2.collect_count AS artCollectCount, t2.publish_time AS artPublishTime, t2.create_time AS artCreateTime, t2.special_topic_id AS artSpecialTopicId, t2.special_topic_title AS artSpecialTopicTitle, t2.is_special_topic AS artIsSpecialTopic, t2.video_url AS artVideoUrl, t2.video_time AS artVideoTime, t2.pics AS artPics, (SELECT count(1) FROM con_article_likes WHERE user_id = ? AND art_id = t2.art_id AND con_article_likes.tenant_id = '1') AS artIsLike, t3.posts_id AS postsId, t3.plate AS postsPlate, t3.topic_id AS postsTopicId, t4.`name` AS postsTopicName, t3.circle_id AS postsCircleId, t3.user_id AS post
 sUserId, t3.type AS postsType, t3.keywords AS postsKeywords, t3.title AS postsTitle, t3.content AS postsContent, t3.pics AS postsPics, t3.is_publish AS postsIsPublish, t3.publish_time AS postsPublishTime, t3.create_time AS postsCreateTime, t3.share_count AS postsShareCount, t3.views_count_base AS postsViewsCount, t3.comment_count AS postsCommentCount, t3.likes_count_base AS postsLikesCount, t3.collect_count AS postsCollectCount, t3.is_recommend AS postsIsRecommend, t3.is_top AS postsIsTop, t3.is_good AS postsIsGood, t3.is_check AS postsIsCheck, t3.is_hot AS postsIsHot, t3.is_private AS postsIsPrivate, t3.video_url AS postsVideoUrl, t3.video_time AS postsVideoTime, (SELECT count(1) FROM con_posts_likes WHERE user_id = ? AND posts_id = t3.posts_id AND con_posts_likes.tenant_id = '1') AS postsIsLike, t1.title AS title, t1.pic AS pic, t3.city AS city, t3.province AS province, t3.city_code AS cityCode, t3.province_code AS provinceCode, t3.lon AS lon, t3.lat AS lat, t3.address AS address,
  t1.pic AS activityImgUrl, t1.sort_order, t1.create_time, (if(find_in_set(?, t1.car_group_code) > 0, 1, 0) + ?) AS car_group_code_order FROM con_recommend t1 LEFT JOIN con_article t2 ON t1.link_id = t2.art_id AND t2.tenant_id = '1' LEFT JOIN con_posts t3 ON t1.link_id = t3.posts_id AND t3.tenant_id = '1' LEFT JOIN con_posts_topic t4 ON t4.topic_id = t3.topic_id AND t1.type = 2 AND t4.tenant_id = '1' WHERE ((t1.type = 1 AND t2.is_deleted = 0 AND t2.status = 1 AND t2.is_special_topic = 0 AND t2.check_sataus = 1) OR (t1.type = 2 AND t3.is_deleted = 0 AND t3.is_private = 1 AND t3.is_check = 1)) AND t1.tenant_id = '1') temp ORDER BY temp.sort_order DESC, temp.create_time DESC LIMIT ?, ?    ::: [null, null, null, null, 0, 10
   `


-- 
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] flower-you commented on issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

Posted by "flower-you (via GitHub)" <gi...@apache.org>.
flower-you commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-1608668877

   but ProjectionEngine is final,can't override. How did you do it?


-- 
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] github-actions[bot] commented on issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #24207:
URL: https://github.com/apache/shardingsphere/issues/24207#issuecomment-1652871655

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


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