flink take single element from stream

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

flink take single element from stream

Georg Heiler
How can I explore a stream in Flink interactively?

Spark has the concept of take/head to extract the first n elements of a dataframe / table.

Is something similar available in Flink for a stream like:

val serializer = new JSONKeyValueDeserializationSchema(false)
val stream = senv.addSource(
    new FlinkKafkaConsumer(
      "tweets-raw-json",
      serializer,
      properties
    ).setStartFromEarliest() // TODO experiment with different start values
  )

stream.head/take

does not seem to be implemented.

Reply | Threaded
Open this post in threaded view
|

Re: flink take single element from stream

Aljoscha Krettek
I'm afraid limit() is not yet available on the Table API but you can use
it via SQL, i.e. sth like "select * FROM (VALUES 'Hello', 'CIAO', 'foo',
'bar') LIMIT 2;" works. You can execute that from the Table API via
`TableEnvironment.executeSql()`.

Best,
Aljoscha

On 09.07.20 17:53, Georg Heiler wrote:

> How can I explore a stream in Flink interactively?
>
> Spark has the concept of take/head to extract the first n elements of a
> dataframe / table.
>
> Is something similar available in Flink for a stream like:
>
> val serializer = new JSONKeyValueDeserializationSchema(false)
> val stream = senv.addSource(
>      new FlinkKafkaConsumer(
>        "tweets-raw-json",
>        serializer,
>        properties
>      ).setStartFromEarliest() // TODO experiment with different start values
>    )
>
> stream.head/take
>
> does not seem to be implemented.
>