Overcoming Fear and Anxiety - Chapter 9: Haters - Sneek Peek
Apache Flink - A Sneek Preview on Language Integrated Queries
-
Upload
fabian-hueske -
Category
Data & Analytics
-
view
152 -
download
0
Transcript of Apache Flink - A Sneek Preview on Language Integrated Queries
![Page 1: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/1.jpg)
Apache
Flink
Language Integrated Queries
(Preview)
Aljoscha Krettek
![Page 2: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/2.jpg)
What is This?
• Declarative Expression API for Flink
• Can freely mix declarative operations and
“classic” operations
• Elegance through conciseness
• Robustness through type analysis
• Speed through code-generation
flink.apache.org 1
![Page 3: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/3.jpg)
Introductory Example
flink.apache.org 2
case class Book(title: String, price: Int, …)
val books = env.fromElements(…)
val result = books.filter('price > 10)
![Page 4: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/4.jpg)
Filter
flink.apache.org 3
val result = books.filter('price > 10 && 'author === "Foo")
![Page 5: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/5.jpg)
Join
flink.apache.org 4
val result = books
.join(authors).where('bAuthor === 'aAuthor && price > 10)
.select('aAuthor, 'aAddress)
![Page 6: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/6.jpg)
Aggregation
flink.apache.org 5
val result = books.group('author).select('author, 'price.avg)
![Page 7: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/7.jpg)
Expressions
flink.apache.org 6
val result = books.select('author.substring(0, 'price.avg + 5))
val result = books.select(('price + 5).avg % 2, 'title.count)
![Page 8: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/8.jpg)
Back to the Classic API
flink.apache.org 7
case class MyResult(avg: Int, cnt: Int)
val result: DataSet[MyResult] = books
.select(('price + 5).avg % 2 as 'avg, 'title.count as 'cnt)
.as[MyResult]
.map { … }
![Page 9: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/9.jpg)
Java API
flink.apache.org 8
DataSet<Row> result = books.select("author", "price.avg + 5")
DataSet<Row> result = books
.join(authors).where("bAuthor = aAuthor && price > 10")
.select("aAuthor", "aAddress")
![Page 10: Apache Flink - A Sneek Preview on Language Integrated Queries](https://reader036.fdocuments.in/reader036/viewer/2022071710/55a6957e1a28ab6d148b469a/html5/thumbnails/10.jpg)
github.com/aljoscha/flink/tree/lin
q
flink.apache.org
github.com/apache/flink
meetup.com/Apache-Flink-
Meetup