github-actions[bot] opened a new issue, #553:
URL: https://github.com/apache/incubator-wayang/issues/553

   implement fetch & offset for java
   
   
https://github.com/apache/incubator-wayang/blob/e17125992e6556b6cb0c07df71b59584de643800/wayang-api/wayang-api-sql/src/main/java/org/apache/wayang/api/sql/calcite/converter/WayangSortVisitor.java#L48
   
   ```java
   
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to you under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
   
   package org.apache.wayang.api.sql.calcite.converter;
   
   import java.util.List;
   import java.util.stream.Collectors;
   
   import org.apache.calcite.rel.RelCollation;
   import org.apache.calcite.rel.RelFieldCollation.Direction;
   import org.apache.calcite.rex.RexLiteral;
   import org.apache.calcite.rex.RexNode;
   
   import 
org.apache.wayang.api.sql.calcite.converter.functions.SortKeyExtractor;
   import org.apache.wayang.api.sql.calcite.rel.WayangSort;
   import org.apache.wayang.basic.data.Record;
   import org.apache.wayang.basic.operators.SortOperator;
   import org.apache.wayang.core.function.TransformationDescriptor;
   import org.apache.wayang.core.plan.wayangplan.Operator;
   
   public class WayangSortVisitor extends WayangRelNodeVisitor<WayangSort> {
   
       WayangSortVisitor(final WayangRelConverter wayangRelConverter) {
           super(wayangRelConverter);
       }
   
       @Override
       Operator visit(final WayangSort wayangRelNode) {
           assert (wayangRelNode.getInputs().size() == 1)
                   : "Sorts must only have one input, but found: " + 
wayangRelNode.getInputs().size();
   
           final Operator childOp = 
wayangRelConverter.convert(wayangRelNode.getInput());
   
           //TODO: implement fetch & offset for java
           final RexNode fetch = wayangRelNode.fetch;
           final RexLiteral offset = (RexLiteral) wayangRelNode.offset;
   
           if (fetch != null || offset != null) throw new 
UnsupportedOperationException("Offset and fetch currently not supported, these 
appear via LIMIT statements in SQL");
           
           final RelCollation collation = wayangRelNode.getCollation();
   
           final List<Direction> collationDirections = 
collation.getFieldCollations().stream()
                   .map(fieldCol -> fieldCol.getDirection())
                   .collect(Collectors.toList());
   
           final List<Integer> collationIndexes = 
collation.getFieldCollations().stream()
                   .map(fieldCol -> fieldCol.getFieldIndex())
                   .collect(Collectors.toList());
   
           final TransformationDescriptor<Record, Record> td = new 
TransformationDescriptor<Record, Record>(
                   new SortKeyExtractor(
                           collationDirections,
                           collationIndexes),
                   Record.class, Record.class);
   
           final SortOperator<Record, Record> sort = new SortOperator<Record, 
Record>(td);
   
           childOp.connectTo(0, sort, 0);
   
           return sort;
       }
   
   }
   
   ```
   
   8da34aa2fd4875652987de045e1fa35aeba85e66


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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to