[ 
https://issues.apache.org/jira/browse/FLINK-2946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15261106#comment-15261106
 ] 

ASF GitHub Bot commented on FLINK-2946:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1926#discussion_r61349569
  
    --- Diff: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/table/test/SortITCase.scala
 ---
    @@ -0,0 +1,147 @@
    +/*
    + * 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.flink.api.scala.table.test
    +
    +import org.apache.flink.api.scala.table._
    +import org.apache.flink.api.scala.util.CollectionDataSets
    +import org.apache.flink.api.scala.{ExecutionEnvironment, _}
    +import org.apache.flink.api.table.{Row, TableEnvironment}
    +import org.apache.flink.api.table.test.utils.TableProgramsTestBase
    +import 
org.apache.flink.api.table.test.utils.TableProgramsTestBase.TableConfigMode
    +import 
org.apache.flink.test.util.MultipleProgramsTestBase.TestExecutionMode
    +import org.apache.flink.test.util.TestBaseUtils
    +import org.junit._
    +import org.junit.runner.RunWith
    +import org.junit.runners.Parameterized
    +
    +import scala.collection.JavaConverters._
    +
    +@RunWith(classOf[Parameterized])
    +class SortITCase(
    +    mode: TestExecutionMode,
    +    configMode: TableConfigMode)
    +  extends TableProgramsTestBase(mode, configMode) {
    +
    +  def getExecutionEnvironment = {
    +    val env = ExecutionEnvironment.getExecutionEnvironment
    +    env.setParallelism(4)
    +    env
    +  }
    +
    +  val tupleDataSetStrings = List((1, 1L, "Hi")
    +    ,(2, 2L, "Hello")
    +    ,(3, 2L, "Hello world")
    +    ,(4, 3L, "Hello world, how are you?")
    +    ,(5, 3L, "I am fine.")
    +    ,(6, 3L, "Luke Skywalker")
    +    ,(7, 4L, "Comment#1")
    +    ,(8, 4L, "Comment#2")
    +    ,(9, 4L, "Comment#3")
    +    ,(10, 4L, "Comment#4")
    +    ,(11, 5L, "Comment#5")
    +    ,(12, 5L, "Comment#6")
    +    ,(13, 5L, "Comment#7")
    +    ,(14, 5L, "Comment#8")
    +    ,(15, 5L, "Comment#9")
    +    ,(16, 6L, "Comment#10")
    +    ,(17, 6L, "Comment#11")
    +    ,(18, 6L, "Comment#12")
    +    ,(19, 6L, "Comment#13")
    +    ,(20, 6L, "Comment#14")
    +    ,(21, 6L, "Comment#15"))
    +
    +  @Test
    +  def testOrderByDesc(): Unit = {
    +    val env = getExecutionEnvironment
    +    val tEnv = TableEnvironment.getTableEnvironment(env, config)
    +
    +    val ds = CollectionDataSets.get3TupleDataSet(env)
    +    val t = ds.toTable(tEnv).orderBy('_1.desc)
    +    implicit def rowOrdering[T <: Product] = Ordering.by((x : T) =>
    +      - x.productElement(0).asInstanceOf[Int])
    +
    +    val expected = sortExpectedly(tupleDataSetStrings)
    +    val results = t.toDataSet[Row].mapPartition(rows => 
Seq(rows.toSeq)).collect()
    +
    +    val result = results.filterNot(_.isEmpty).sortBy(p => 
p.min).reduceLeft(_ ++ _)
    --- End diff --
    
    `p.min` should be `p.head` because p should already be sorted (same applies 
for the other tests as well).


> Add orderBy() to Table API
> --------------------------
>
>                 Key: FLINK-2946
>                 URL: https://issues.apache.org/jira/browse/FLINK-2946
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API
>            Reporter: Timo Walther
>            Assignee: Dawid Wysakowicz
>
> In order to implement a FLINK-2099 prototype that uses the Table APIs code 
> generation facilities, the Table API needs a sorting feature.
> I would implement it the next days. Ideas how to implement such a sorting 
> feature are very welcome. Is there any more efficient way instead of 
> {{.sortPartition(...).setParallism(1)}}? Is it better to sort locally on the 
> nodes first and finally sort on one node afterwards?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to