Try:

xx.orderBy('id.desc, 'value1.asc)


*Best Regards,*
*Zhenghua Gao*


On Sat, Mar 16, 2019 at 10:28 AM 刘 文 <[email protected]>
wrote:

>
> 输出结果,只按id降序排序,没有按value1升序排序。
>
>
>
>
>
>
>
> package
> com.opensourceteams.module.bigdata.flink.example.tableapi.operation.orderBy
>
> import org.apache.flink.api.scala.{ExecutionEnvironment, _}
> import org.apache.flink.table.api.TableEnvironment
> import org.apache.flink.table.api.scala._
>
> object Run {
>
>
>   def main(args: Array[String]): Unit = {
>
>     val env = ExecutionEnvironment.getExecutionEnvironment
>     val tableEnv = TableEnvironment.getTableEnvironment(env)
>
>     env.setParallelism(1)
>
>     val dataSet = env.fromElements( (1,"a",10),(2,"b",20)
> ,(20,"f",200),(3,"c",30) )
>
>
>
>     //从dataset转化为 table
>     val table = tableEnv.fromDataSet(dataSet)
>
>     //注册table
>     tableEnv.registerTable("user1",table)
>
>
>     //查询table 所有数据
>     tableEnv.scan("user1").as('id,'name,'value1)
>       //.orderBy('id.asc)  //按id列,升序排序(注意是按分区来排序)
>       .orderBy('id.desc)
>       .orderBy('value1.asc)
>
>       .first(1000)
>
>       //print 输出 (相当于sink)
>       .print()
>
>
>     /**
>       * 输出结果
>       *
>       * 20,f,200
>       * 3,c,30
>       * 2,b,20
>       * 1,a,10
>       */
>
>
>
>   }
>
> }
>
>

回复