-
Notifications
You must be signed in to change notification settings - Fork 460
[connector/flink] Read support for fluss primary key table changelogs system table/ cdc events #510
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
Open
MehulBatra
wants to merge
10
commits into
apache:main
Choose a base branch
from
MehulBatra:flink-connector-changelog-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0555e07
[connector] flink read support for fluss primary key table changelog …
MehulBatra 86722e8
added license to newly added file & removed unwanted comments
MehulBatra c70f284
changes to resolve comments including composite design for convertor,…
MehulBatra 49eefc8
unit-test for changelog and flinktablesource, factory changes for cha…
MehulBatra 3cdf105
Integration tests to support changeLog reads
MehulBatra b105783
changed licenses
MehulBatra dbb0088
Adjust the projected fields with the metadata fields for projection a…
MehulBatra 7a91a41
Integration to test for full read, partial read columns and no sink s…
MehulBatra 1330d26
Resolve conflicts and adapted changeType enum
MehulBatra 9f94c07
pass sanity check test
MehulBatra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...or-flink/src/main/java/com/alibaba/fluss/connector/flink/utils/ChangelogRowConverter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright (c) 2024 Alibaba Group Holding Ltd. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.alibaba.fluss.connector.flink.utils; | ||
|
|
||
| import com.alibaba.fluss.client.table.scanner.ScanRecord; | ||
| import com.alibaba.fluss.types.RowType; | ||
|
|
||
| import org.apache.flink.table.data.GenericRowData; | ||
| import org.apache.flink.table.data.RowData; | ||
|
|
||
| public class ChangelogRowConverter extends FlussRowToFlinkRowConverter { | ||
MehulBatra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public ChangelogRowConverter(RowType rowType) { | ||
| super(rowType); | ||
| } | ||
|
|
||
| public RowData toFlinkRowData(ScanRecord scanRecord) { | ||
| RowData baseRowData = super.toFlinkRowData(scanRecord); | ||
| GenericRowData rowWithMetadata = new GenericRowData(baseRowData.getArity() + 3); | ||
| rowWithMetadata.setRowKind(baseRowData.getRowKind()); | ||
|
|
||
| for (int i = 0; i < baseRowData.getArity(); i++) { | ||
| rowWithMetadata.setField(i, baseRowData.getRawValue(i)); | ||
MehulBatra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| int baseArity = baseRowData.getArity(); | ||
| String changeType; | ||
| switch (scanRecord.getRowKind()) { | ||
| case INSERT: | ||
| changeType = "+I"; | ||
| break; | ||
| case UPDATE_BEFORE: | ||
| changeType = "-U"; | ||
| break; | ||
| case UPDATE_AFTER: | ||
| changeType = "+U"; | ||
| break; | ||
| case DELETE: | ||
| changeType = "-D"; | ||
| break; | ||
| default: | ||
| changeType = "+I"; | ||
| break; | ||
| } | ||
| rowWithMetadata.setField(baseArity, changeType); | ||
| rowWithMetadata.setField(baseArity + 1, scanRecord.logOffset()); | ||
| rowWithMetadata.setField(baseArity + 2, scanRecord.timestamp()); | ||
|
|
||
| return rowWithMetadata; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.