apache flink - a sneek preview on language integrated queries

10
Apache Flink Language Integrated Queries (Preview) Aljoscha Krettek [email protected]

Upload: fabian-hueske

Post on 16-Jul-2015

152 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Apache Flink - A Sneek Preview on Language Integrated Queries

Apache

Flink

Language Integrated Queries

(Preview)

Aljoscha Krettek

[email protected]

Page 2: Apache Flink - A Sneek Preview on Language Integrated Queries

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

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

Filter

flink.apache.org 3

val result = books.filter('price > 10 && 'author === "Foo")

Page 5: Apache Flink - A Sneek Preview on Language Integrated Queries

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

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

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

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

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

github.com/aljoscha/flink/tree/lin

q

flink.apache.org

github.com/apache/flink

meetup.com/Apache-Flink-

Meetup