How to sorted by flink sql?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to sorted by flink sql?

刘 文
hi all,
   Results are not sorted











package com.opensourceteams.module.bigdata.flink.example.sql.test

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.table.api.scala._
import org.apache.flink.api.scala._
import org.apache.flink.table.api.TableEnvironment

object Run {



def main(args: Array[String]): Unit = {


val env = ExecutionEnvironment.getExecutionEnvironment


val dataSet = env.fromElements(("a",15,"male"),("b",45,"female"),("d",25,"male"),("c",35,"female"))

val tableEnv = TableEnvironment.getTableEnvironment(env)

tableEnv.registerDataSet("user1",dataSet,'name,'age,'sex)


/**
* default sort
a,15,male
b,45,female
d,25,male
c,35,female
*/


/**
* sort by age ,Results are not sorted
* a,15,male
* b,45,female
* c,35,female
* d,25,male
*/

tableEnv.sqlQuery("select name,age,sex FROM user1 order by age desc ")
.first(100).print()


}

}



Best,
thinktothings