@ParametersAreNonnullByDefault public class EventTableDescriptorBuilder extends Object
EventTableDescriptorBuilder builder = EventTableDescriptorBuilder.from(
Arrays.asList(
"https://schema.wikimedia.org/repositories/primary/jsonschema",
"https://schema.wikimedia.org/repositories/secondary/jsonschema",
),
"https://meta.wikimedia.org/w/api.php"
);
Build a DataGen Table:
Table t = tableEnv.from(
builder
.connector("datagen")
.eventStream("mediawiki.page-create")
.option("number-of-rows", "10")
.build()
)
);
Build a Kafka Table:
Table t = tableEnv.from(
builder
.eventStream("mediawiki.page-create")
.setupKafka(
"localhost:9092",
"my_consumer_group",
true // If should auto-add a kafka_timestamp watermark virtual field.
)
.build()
)
);
Constructor and Description |
---|
EventTableDescriptorBuilder(EventStreamFactory eventStreamFactory) |
Modifier and Type | Method and Description |
---|---|
org.apache.flink.table.api.TableDescriptor |
build()
Applies all the collected configs and options to
build a TableDescriptor using information from the EventStream.
|
EventTableDescriptorBuilder |
clear()
Clears all collected configs and options from this EventTableDescriptorBuilder
so that it can be used to build another TableDescriptor.
|
EventTableDescriptorBuilder |
connector(String connectorIdentifier)
Sets the connector.
|
EventTableDescriptorBuilder |
eventStream(EventStream eventStream)
Sets the EventStream that will be used to build the TableDescriptor.
|
EventTableDescriptorBuilder |
eventStream(String streamName)
Sets the EventStream by streamName that will be used to build the TableDescriptor.
|
EventTableDescriptorBuilder |
format(String format)
Sets the format for the TableDescriptor.Builder.
|
static EventTableDescriptorBuilder |
from(List<String> eventSchemaBaseUris,
String eventStreamConfigUri)
EventTableDescriptorBuilder factory method.
|
static EventTableDescriptorBuilder |
from(List<String> eventSchemaBaseUris,
String eventStreamConfigUri,
Map<String,String> httpClientRoutes)
EventTableDescriptorBuilder factory method.
|
EventStreamFactory |
getEventStreamFactory()
Convenience method to get the EventStreamFactory used
by this EventTableDescriptorBuilder.
|
org.apache.flink.table.api.Schema.Builder |
getSchemaBuilder()
Use this to get the schemaBuilder for the eventStream
in order to augment and reset it before calling build().
|
EventTableDescriptorBuilder |
option(String key,
String value)
Sets a single TableDescriptor.Builder option.
|
EventTableDescriptorBuilder |
options(Map<String,String> options)
Sets the TableDescriptor.Builder options.
|
EventTableDescriptorBuilder |
partitionedBy(String... partitionKeys)
Sets the partitionKeys for the TableDescriptor.Builder.
|
EventTableDescriptorBuilder |
schemaBuilder(org.apache.flink.table.api.Schema.Builder schemaBuilder)
Sets the Schema.Builder.
|
EventTableDescriptorBuilder |
setupKafka(String bootstrapServers,
String consumerGroup)
Helper to aid in setting up a kafka connector for the EventStream.
|
EventTableDescriptorBuilder |
withKafkaTimestampAsWatermark()
Adds a "kafka_timestamp" column to the schema and uses
it as the watermark field with a default watermark delay of 10 seconds.
|
EventTableDescriptorBuilder |
withKafkaTimestampAsWatermark(String columnName,
int watermarkDelaySeconds)
Adds kafka timestamp as a virtual column to the schema,
and uses it as the watermark with a delay of watermarkDelaySeconds.
|
EventTableDescriptorBuilder |
withKafkaTimestampAsWatermark(String columnName,
String sqlExpression)
Adds kafka timestamp as a virtual column to the schema,
and uses it as the watermark.
|
public EventTableDescriptorBuilder(EventStreamFactory eventStreamFactory)
@Nonnull public static EventTableDescriptorBuilder from(List<String> eventSchemaBaseUris, String eventStreamConfigUri)
eventSchemaBaseUris
- URIs from which to fetch event JSONSchemas.eventStreamConfigUri
- URI from which to fetch event stream config.@Nonnull public static EventTableDescriptorBuilder from(List<String> eventSchemaBaseUris, String eventStreamConfigUri, Map<String,String> httpClientRoutes)
eventSchemaBaseUris
- URIs from which to fetch event JSONSchemas.eventStreamConfigUri
- URI from which to fetch event stream config.httpClientRoutes
- Map of source to dest http client routes.
E.g. "https://meta.wikimedia.org" to "https://api-ro.wikimedia.org"
If null, no special routing will be configured.@Nonnull public EventStreamFactory getEventStreamFactory()
@Nonnull public EventTableDescriptorBuilder connector(String connectorIdentifier)
connectorIdentifier
- A valid and registered Flink Table Connector Factory Identifier string.
e.g. "kafka" or "filesystem".@Nonnull public EventTableDescriptorBuilder eventStream(EventStream eventStream)
@Nonnull public EventTableDescriptorBuilder eventStream(String streamName)
streamName
- Name of the EventStream, must be declared in EventStreamConfig.@Nonnull public EventTableDescriptorBuilder schemaBuilder(org.apache.flink.table.api.Schema.Builder schemaBuilder)
@Nonnull public EventTableDescriptorBuilder options(Map<String,String> options)
@Nonnull public EventTableDescriptorBuilder option(String key, String value)
@Nonnull public EventTableDescriptorBuilder format(String format)
@Nonnull public EventTableDescriptorBuilder partitionedBy(String... partitionKeys)
@Nonnull public EventTableDescriptorBuilder setupKafka(String bootstrapServers, String consumerGroup)
option("properties.auto.offset.reset", "earliest")
This does not set the key format or hoist any metadata fields
(like kafka_timestamp) into the schema.
See withKafkaTimestampAsWatermark to help use the kafka timestamp
as the watermark.bootstrapServers
- Kafka bootstrap.servers property.consumerGroup
- Kafka consumer.group.id property.@Nonnull public EventTableDescriptorBuilder withKafkaTimestampAsWatermark()
@Nonnull public EventTableDescriptorBuilder withKafkaTimestampAsWatermark(String columnName, int watermarkDelaySeconds)
columnName
- Name of the timestamp column to add to the schema.watermarkDelaySeconds
- Seconds to delay the watermark by.@Nonnull public EventTableDescriptorBuilder withKafkaTimestampAsWatermark(String columnName, String sqlExpression)
Schema.Builder#watermark(String, String)
columnName
- Name of the column to add to the schema.sqlExpression
- SQL expression to use for the watermark.
This should probably refer to the columnName, e.g. "$columnName - INTERVAL '30' seconds"@Nonnull public org.apache.flink.table.api.Schema.Builder getSchemaBuilder()
schemaBuilder(modifiedSchemaBuilder)
to apply your changes
before calling build()
.@Nonnull public org.apache.flink.table.api.TableDescriptor build()
@Nonnull public final EventTableDescriptorBuilder clear()
Copyright © 2024. All rights reserved.