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

[GitHub] [shardingsphere] fangs95 commented on issue #24207: java.sql.SQLFeatureNotSupportedException: can't get index from columnLabel[xxxxxxxxx]

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