-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Feature][Flink] Add flink version 1.20.1 support #9576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Good pr |
...-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/FlinkExecution.java
Outdated
Show resolved
Hide resolved
...ation-flink-20/src/main/java/org/apache/seatunnel/translation/flink/source/SplitWrapper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need new flink 1.20.1 test container to verify it. https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-e2e-common/src/test/java/org/apache/seatunnel/e2e/common/container/flink
The test container for Flink 1.20 has been added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for Flink 1.20.1 to SeaTunnel's translation layer by creating new Flink 1.20-specific implementations that use Flink's official sink2 API instead of the fragile reflection-based approach. The changes ensure compatibility while maintaining the same public API for users.
- Creates Flink 1.20 translation layer with modern sink2 API integration
- Adds comprehensive Flink 1.20 starter components and build configuration
- Updates E2E testing infrastructure to include Flink 1.20 support
Reviewed Changes
Copilot reviewed 49 out of 51 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
seatunnel-translation/seatunnel-translation-flink/seatunnel-translation-flink-20/ | Complete Flink 1.20 translation layer implementation using sink2 API |
seatunnel-core/seatunnel-flink-starter/seatunnel-flink-20-starter/ | Flink 1.20 starter implementation with refactored architecture |
seatunnel-e2e/ | E2E test infrastructure updates for Flink 1.20 compatibility |
seatunnel-dist/ | Distribution assembly configuration for Flink 1.20 components |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...ansforms-v2-e2e-part-1/src/test/java/org/apache/seatunnel/e2e/transform/TestEmbeddingIT.java
Outdated
Show resolved
Hide resolved
...ink-20/src/main/java/org/apache/seatunnel/translation/flink/sink/FlinkSinkWriterContext.java
Show resolved
Hide resolved
...e-common/src/test/java/org/apache/seatunnel/e2e/common/container/flink/Flink20Container.java
Show resolved
Hide resolved
...er/src/main/java/org/apache/seatunnel/core/starter/flink/execution/SinkExecuteProcessor.java
Outdated
Show resolved
Hide resolved
...ain/java/org/apache/seatunnel/core/starter/flink/execution/AbstractSinkExecuteProcessor.java
Outdated
Show resolved
Hide resolved
...ink-20/src/main/java/org/apache/seatunnel/translation/flink/sink/FlinkSinkWriterContext.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been replied to now.
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class FlinkExecution implements TaskExecution { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there is additional logic for the createFlink20JobMetricsSummary method in FlinkExecution
...rc/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/PaimonSourceReader.java
Outdated
Show resolved
Hide resolved
...tor-v2-e2e/connector-doris-e2e/src/test/resources/doris_source_and_sink_with_custom_sql.conf
Outdated
Show resolved
Hide resolved
...connector-v2-e2e/connector-file-sftp-e2e/src/test/resources/text/fake_to_sftp_file_text.conf
Show resolved
Hide resolved
...2e-common/src/test/java/org/apache/seatunnel/e2e/common/container/AbstractTestContainer.java
Show resolved
Hide resolved
...ink-20/src/main/java/org/apache/seatunnel/translation/flink/sink/FlinkSinkWriterContext.java
Outdated
Show resolved
Hide resolved
...ink-20/src/main/java/org/apache/seatunnel/translation/flink/sink/FlinkSinkWriterContext.java
Outdated
Show resolved
Hide resolved
...ain/java/org/apache/seatunnel/core/starter/flink/execution/AbstractSinkExecuteProcessor.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/seatunnel/core/starter/flink/execution/SinkExecuteProcessor.java
Outdated
Show resolved
Hide resolved
...ansforms-v2-e2e-part-1/src/test/java/org/apache/seatunnel/e2e/transform/TestEmbeddingIT.java
Outdated
Show resolved
Hide resolved
It has been added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
...-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/FlinkExecution.java
Outdated
Show resolved
Hide resolved
...-20/src/main/java/org/apache/seatunnel/translation/flink/metric/FlinkAccumulatorCounter.java
Outdated
Show resolved
Hide resolved
...-20/src/main/java/org/apache/seatunnel/translation/flink/metric/FlinkAccumulatorCounter.java
Outdated
Show resolved
Hide resolved
...ation-flink-20/src/main/java/org/apache/seatunnel/translation/flink/metric/FlinkCounter.java
Outdated
Show resolved
Hide resolved
...k-20/src/main/java/org/apache/seatunnel/translation/flink/metric/FlinkJobMetricsSummary.java
Outdated
Show resolved
Hide resolved
...slation-flink-20/src/main/java/org/apache/seatunnel/translation/flink/metric/FlinkMeter.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
if (metricGroup == null) { | ||
Counter noOpCounter = new NoOpCounter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need NoOpCounter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need NoOpCounter?
When metricGroup == null (e.g., in scenarios such as certain test cases, initialization phases, or when the context is not in the Flink Runtime environment), returning a NoOp (No Operation) instance prevents NullPointerException and ensures the business logic remains operational.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's werid. Why other flink version does not need this?
} | ||
|
||
@Override | ||
protected FlinkJobMetricsSummary createJobMetricsSummary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After remove logs, I found this method same as method in common module. We shoud do some refactor.
return accumulator; | ||
} | ||
|
||
public void sync() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's for?
private final org.apache.flink.metrics.Counter flinkCounter; | ||
private final LongCounter accumulator; | ||
private final RuntimeContext runtimeContext; | ||
private final java.util.concurrent.atomic.AtomicLong localCount = | ||
new java.util.concurrent.atomic.AtomicLong(0L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need two fields to store value?
} | ||
|
||
private String getStandardAccumulatorName(String originalName) { | ||
if (originalName.contains("SinkWriteCount") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as #9576 (comment)
} | ||
|
||
if (metricGroup == null) { | ||
Counter noOpCounter = new NoOpCounter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's werid. Why other flink version does not need this?
#9513
Purpose of this pull request
This pull request fixes the Flink 1.20 compatibility issue in the SeaTunnel Flink translation layer. The current implementation uses reflection to access internal StreamingRuntimeContext from SourceReaderContext, which is fragile and may break with Flink version updates.
Does this PR introduce any user-facing change?
No. This is an internal implementation fix that maintains the same public API behavior. Users will continue to use the same SeaTunnel connector APIs without any changes. The metrics functionality remains identical from the user perspective.
How was this patch tested?
Manual Testing:
Built SeaTunnel with Flink 1.20 dependencies
Ran sample connector jobs to verify metrics collection
Confirmed no reflection-related errors in logs
Validated metrics appear correctly in Flink Web UI
Check list
New License Guide