-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[cdc] Update flink.cdc.version to 3.5.0 and add FlinkCDC to Paimon converter. #6358
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
lvyanquan
wants to merge
10
commits into
apache:master
Choose a base branch
from
lvyanquan:cdc-version
base: master
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0e68103
[cdc] Update flink.cdc.version to 3.5.0.
lvyanquan aee914c
[cdc] Add PaimonMetadataApplier.
lvyanquan 2a0c861
[cdc] Add TypeConverter and DataConverter.
lvyanquan 9838600
[cdc] Add TypeConverter and DataConverter.
lvyanquan 529b740
Fix unstable CI
yuxiqian 065d61a
[cdc] Update flink.cdc.version to 3.5.0.
lvyanquan bc544e5
[cdc] Add PaimonMetadataApplier.
lvyanquan 5b4eaab
[cdc] Add TypeConverter and DataConverter.
lvyanquan 1176869
[cdc] Add TypeConverter and DataConverter.
lvyanquan bb323b3
[cdc][contrib] Fixes CDC test case failure
lvyanquan 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
362 changes: 362 additions & 0 deletions
362
...-cdc/src/main/java/org/apache/paimon/flink/pipeline/cdc/schema/PaimonMetadataApplier.java
Large diffs are not rendered by default.
Oops, something went wrong.
152 changes: 152 additions & 0 deletions
152
...k-cdc/src/main/java/org/apache/paimon/flink/pipeline/cdc/schema/SchemaChangeProvider.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,152 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.paimon.flink.pipeline.cdc.schema; | ||
|
|
||
| import org.apache.paimon.flink.pipeline.cdc.util.FlinkCDCToPaimonTypeConverter; | ||
| import org.apache.paimon.schema.SchemaChange; | ||
|
|
||
| import org.apache.flink.cdc.common.event.AddColumnEvent; | ||
| import org.apache.flink.cdc.common.schema.Column; | ||
| import org.apache.flink.cdc.common.types.DataType; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * The SchemaChangeProvider class provides static methods to create SchemaChange objects that | ||
| * represent different types of schema modifications. | ||
| */ | ||
| public class SchemaChangeProvider { | ||
|
|
||
| /** | ||
| * Creates a SchemaChange object for adding a column without specifying its position. | ||
| * | ||
| * @param columnWithPosition The ColumnWithPosition object containing the column details and its | ||
| * intended position within the schema. | ||
| * @return A SchemaChange object representing the addition of a column. | ||
| */ | ||
| public static List<SchemaChange> add(AddColumnEvent.ColumnWithPosition columnWithPosition) { | ||
| List<SchemaChange> result = new ArrayList<>(); | ||
| result.add( | ||
| SchemaChange.addColumn( | ||
| columnWithPosition.getAddColumn().getName(), | ||
| FlinkCDCToPaimonTypeConverter.convertFlinkCDCDataTypeToPaimonDataType( | ||
| columnWithPosition.getAddColumn().getType()), | ||
| columnWithPosition.getAddColumn().getComment())); | ||
| // if default value express exists, we need to set the default value to the table | ||
| // option | ||
| Column column = columnWithPosition.getAddColumn(); | ||
| Optional.ofNullable( | ||
| FlinkCDCToPaimonTypeConverter.convertFlinkCDCDefaultValueToValidValue( | ||
| column.getDefaultValueExpression(), column.getType())) | ||
| .ifPresent( | ||
| value -> { | ||
| result.add( | ||
| SchemaChange.updateColumnDefaultValue( | ||
| new String[] {column.getName()}, value)); | ||
| }); | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a SchemaChange object for adding a column with a specified position. | ||
| * | ||
| * @param columnWithPosition The ColumnWithPosition object containing the column details and its | ||
| * intended position within the schema. | ||
| * @param move The move operation to indicate the column's new position. | ||
| * @return A SchemaChange object representing the addition of a column with position | ||
| * information. | ||
| */ | ||
| public static List<SchemaChange> add( | ||
| AddColumnEvent.ColumnWithPosition columnWithPosition, SchemaChange.Move move) { | ||
| List<SchemaChange> result = new ArrayList<>(); | ||
| result.add( | ||
| SchemaChange.addColumn( | ||
| columnWithPosition.getAddColumn().getName(), | ||
| FlinkCDCToPaimonTypeConverter.convertFlinkCDCDataTypeToPaimonDataType( | ||
| columnWithPosition.getAddColumn().getType()), | ||
| columnWithPosition.getAddColumn().getComment(), | ||
| move)); | ||
| // if default value express exists, we need to set the default value to the table | ||
| // option | ||
| Column column = columnWithPosition.getAddColumn(); | ||
| Optional.ofNullable( | ||
| FlinkCDCToPaimonTypeConverter.convertFlinkCDCDefaultValueToValidValue( | ||
| column.getDefaultValueExpression(), column.getType())) | ||
| .ifPresent( | ||
| value -> { | ||
| result.add( | ||
| SchemaChange.updateColumnDefaultValue( | ||
| new String[] {column.getName()}, value)); | ||
| }); | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a SchemaChange object to update the data type of a column. | ||
| * | ||
| * @param oldColumnName The name of the column whose data type is to be updated. | ||
| * @param newType The new DataType for the column. | ||
| * @return A SchemaChange object representing the update of the column's data type. | ||
| */ | ||
| public static SchemaChange updateColumnType(String oldColumnName, DataType newType) { | ||
| return SchemaChange.updateColumnType( | ||
| oldColumnName, | ||
| FlinkCDCToPaimonTypeConverter.convertFlinkCDCDataTypeToPaimonDataType(newType)); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a SchemaChange object for renaming a column. | ||
| * | ||
| * @param oldColumnName The current name of the column to be renamed. | ||
| * @param newColumnName The new name for the column. | ||
| * @return A SchemaChange object representing the renaming of a column. | ||
| */ | ||
| public static List<SchemaChange> rename( | ||
| String oldColumnName, String newColumnName, Map<String, String> options) { | ||
| List<SchemaChange> result = new ArrayList<>(); | ||
| result.add(SchemaChange.renameColumn(oldColumnName, newColumnName)); | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a SchemaChange object for dropping a column. | ||
| * | ||
| * @param columnName The name of the column to be dropped. | ||
| * @return A SchemaChange object representing the deletion of a column. | ||
| */ | ||
| public static List<SchemaChange> drop(String columnName) { | ||
| List<SchemaChange> result = new ArrayList<>(); | ||
| result.add(SchemaChange.dropColumn(columnName)); | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a SchemaChange object for setting an option. | ||
| * | ||
| * @param key The key of the option to be set. | ||
| * @param value The value of the option to be set. | ||
| * @return A SchemaChange object representing the setting of an option. | ||
| */ | ||
| public static SchemaChange setOption(String key, String value) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused method. |
||
| return SchemaChange.setOption(key, value); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
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.
Shall we describe why we need to make changes like this in non-Paimon-Flink-CDC classes? I suppose these changes are along with the Flink CDC version upgrade from 3.1 to 3.5, but not quite sure why we need to make such changes. We can add some details to the description section of this PR.
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.
IIUC due to technical limitations, PostgreSQL CDC does not support capturing DDL events or emitting any schema change events. In earlier versions this method (
includeSchemaChanges) is presented but has no effect at all, and got removed in apache/flink-cdc#3464.