Skip to main content
Ctrl+K
PyFlink 1.20+vvr.11.7.dev0 documentation - Home PyFlink 1.20+vvr.11.7.dev0 documentation - Home
  • API Reference
  • Examples
  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataStream
    • StreamExecutionEnvironment
    • DataStream
    • Functions
    • State
    • Timer
    • Window
    • Checkpoint
    • Side Outputs
    • Asynchronous I/O
    • Connectors
    • Formats
  • PyFlink DataFrame
  • PyFlink Common
  • API Reference
  • PyFlink DataStream
  • Connectors
  • pyflink.datastream.connectors.kafka.KafkaRecordSerializationSchemaBuilder

pyflink.datastream.connectors.kafka.KafkaRecordSerializationSchemaBuilder#

class KafkaRecordSerializationSchemaBuilder[source]#

Builder to construct KafkaRecordSerializationSchema.

Example:

>>> KafkaRecordSerializationSchema.builder() \
...     .set_topic('topic') \
...     .set_key_serialization_schema(SimpleStringSchema()) \
...     .set_value_serialization_schema(SimpleStringSchema()) \
...     .build()

And the sink topic can be calculated dynamically from each record:

>>> KafkaRecordSerializationSchema.builder() \
...     .set_topic_selector(lambda row: 'topic-' + row['category']) \
...     .set_value_serialization_schema(
...         JsonRowSerializationSchema.builder().with_type_info(ROW_TYPE).build()) \
...     .build()

It is necessary to configure exactly one serialization method for the value and a topic.

Added in version 1.16.0.

Methods

build()

Constructs the KafkaRecordSerializationSchemaBuilder with the configured properties.

set_key_serialization_schema(...)

Sets a SerializationSchema which is used to serialize the incoming element to the key of the producer record.

set_topic(topic)

Sets a fixed topic which used as destination for all records.

set_topic_selector(topic_selector)

Sets a topic selector which computes the target topic for every incoming record.

set_value_serialization_schema(...)

Sets a SerializationSchema which is used to serialize the incoming element to the value of the producer record.

previous

pyflink.datastream.connectors.kafka.KafkaRecordSerializationSchema

next

pyflink.datastream.connectors.kafka.KafkaTopicSelector

On this page
  • KafkaRecordSerializationSchemaBuilder

This Page

  • Show Source

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.16.1.