Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions auron-flink-extension/auron-flink-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<artifactId>auron-flink-runtime</artifactId>
<name>Apache Auron Flink Runtime ${flink.version}</name>
<description>Apache Auron Flink Project</description>
<properties>
<kafka.version>3.4.0</kafka.version>
</properties>
<dependencies>
<!-- Auron dependencies -->
<dependency>
Expand Down Expand Up @@ -72,6 +75,13 @@
<scope>provided</scope>
</dependency>

<!-- Kafka client for partition metadata discovery -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.apache.auron</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public DynamicTableSource createDynamicTableSource(Context context) {
final FactoryUtil.TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);
final ReadableConfig tableOptions = helper.getOptions();
try {
String kafkaPropertiesJson = mapper.writeValueAsString(
getKafkaProperties(context.getCatalogTable().getOptions()));
Map<String, String> formatConfig = new HashMap<>();
String format = tableOptions.getOptional(FactoryUtil.FORMAT).get();
formatConfig.put(KAFKA_PB_FORMAT_NESTED_COL_MAPPING_FIELD, tableOptions.get(NESTED_COLS_FIELD_MAPPING));
Expand All @@ -105,7 +103,7 @@ public DynamicTableSource createDynamicTableSource(Context context) {
return new AuronKafkaDynamicTableSource(
context.getCatalogTable().getSchema().toPhysicalRowDataType(),
tableOptions.get(TOPIC),
kafkaPropertiesJson,
getKafkaProperties(context.getCatalogTable().getOptions()),
format,
formatConfig,
tableOptions.get(BUFFER_SIZE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
package org.apache.auron.flink.connector.kafka;

import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import javax.annotation.Nullable;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.connector.ChangelogMode;
import org.apache.flink.table.connector.ProviderContext;
import org.apache.flink.table.connector.source.DataStreamScanProvider;
import org.apache.flink.table.connector.source.DynamicTableSource;
import org.apache.flink.table.connector.source.ScanTableSource;
import org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.types.DataType;
import org.apache.flink.table.types.logical.LogicalType;
Expand All @@ -34,20 +38,22 @@
/**
* A {@link DynamicTableSource} for Auron Kafka.
*/
public class AuronKafkaDynamicTableSource implements ScanTableSource {
public class AuronKafkaDynamicTableSource implements ScanTableSource, SupportsWatermarkPushDown {

private final DataType physicalDataType;
private final String kafkaTopic;
private final String kafkaPropertiesJson;
private final Properties kafkaProperties;
private final String format;
private final Map<String, String> formatConfig;
private final int bufferSize;
private final String startupMode;
/** Watermark strategy that is used to generate per-partition watermark. */
protected @Nullable WatermarkStrategy<RowData> watermarkStrategy;

public AuronKafkaDynamicTableSource(
DataType physicalDataType,
String kafkaTopic,
String kafkaPropertiesJson,
Properties kafkaProperties,
String format,
Map<String, String> formatConfig,
int bufferSize,
Expand All @@ -56,7 +62,7 @@ public AuronKafkaDynamicTableSource(
Preconditions.checkArgument(physicalType.is(LogicalTypeRoot.ROW), "Row data type expected.");
this.physicalDataType = physicalDataType;
this.kafkaTopic = kafkaTopic;
this.kafkaPropertiesJson = kafkaPropertiesJson;
this.kafkaProperties = kafkaProperties;
this.format = format;
this.formatConfig = formatConfig;
this.bufferSize = bufferSize;
Expand All @@ -75,11 +81,16 @@ public ScanRuntimeProvider getScanRuntimeProvider(ScanContext scanContext) {
physicalDataType.getLogicalType(),
auronOperatorId,
kafkaTopic,
kafkaPropertiesJson,
kafkaProperties,
format,
formatConfig,
bufferSize,
startupMode);

if (watermarkStrategy != null) {
sourceFunction.assignTimestampsAndWatermarks(watermarkStrategy);
}

return new DataStreamScanProvider() {

@Override
Expand All @@ -98,11 +109,16 @@ public boolean isBounded() {
@Override
public DynamicTableSource copy() {
return new AuronKafkaDynamicTableSource(
physicalDataType, kafkaTopic, kafkaPropertiesJson, format, formatConfig, bufferSize, startupMode);
physicalDataType, kafkaTopic, kafkaProperties, format, formatConfig, bufferSize, startupMode);
}

@Override
public String asSummaryString() {
return "Auron Kafka Dynamic Table Source";
}

@Override
public void applyWatermark(WatermarkStrategy<RowData> watermarkStrategy) {
this.watermarkStrategy = watermarkStrategy;
}
}
Loading
Loading