guimingyue commented on a change in pull request #10889:
URL: https://github.com/apache/shardingsphere/pull/10889#discussion_r657186553



##########
File path: 
shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/converter/SqlNodeConverter.java
##########
@@ -17,20 +17,55 @@
 
 package org.apache.shardingsphere.infra.optimize.core.convert.converter;
 
+import com.google.common.collect.Lists;
 import org.apache.calcite.sql.SqlNode;
+import 
org.apache.shardingsphere.infra.optimize.core.convert.converter.impl.ColumnOrderByItemSqlNodeConverter;
 import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ColumnOrderByItemSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ExpressionOrderByItemSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.IndexOrderByItemSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.OrderByItemSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.TextOrderByItemSegment;
 
+import java.util.Collection;
+import java.util.List;
 import java.util.Optional;
 
 /**
  * SqlNode converter.
  */
-public interface SqlNodeConverter<T extends ASTNode> {
+public interface SqlNodeConverter<T extends ASTNode, R extends SqlNode> {
     
     /**
      *  Convert.
      * @param astNode ast node
      * @return sqlNode optional
      */
-    Optional<SqlNode> convert(T astNode);
+    Optional<R> convert(T astNode);
+
+    /**
+     * Convert order by items.
+     * @param orderByItems order by item list.
+     * @return a collection of order by item <code>SqlNode</code>
+     */
+    default List<SqlNode> convertOrderByItems(final 
Collection<OrderByItemSegment> orderByItems) {

Review comment:
       I placed this method in both abstract super class and util class two 
days ago,  and use a default method at last but I was not sure. Static util 
method is much better? 




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