-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[FLINK-35242] Supports per-SE type configuration & "lenient" evolution behavior #3339
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
Changes from all commits
55055aa
5281e71
a18def4
18a5f39
7a2a562
d9a525c
862db2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * 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.flink.cdc.common.event; | ||
|
|
||
| import org.apache.flink.cdc.common.annotation.PublicEvolving; | ||
|
|
||
| /** An enumeration of schema change event types for {@link SchemaChangeEvent}. */ | ||
| @PublicEvolving | ||
| public enum SchemaChangeEventType { | ||
| ADD_COLUMN, | ||
| ALTER_COLUMN_TYPE, | ||
| CREATE_TABLE, | ||
| DROP_COLUMN, | ||
| RENAME_COLUMN; | ||
|
|
||
| public static SchemaChangeEventType ofEvent(SchemaChangeEvent event) { | ||
| if (event instanceof AddColumnEvent) { | ||
| return ADD_COLUMN; | ||
| } else if (event instanceof AlterColumnTypeEvent) { | ||
| return ALTER_COLUMN_TYPE; | ||
| } else if (event instanceof CreateTableEvent) { | ||
| return CREATE_TABLE; | ||
| } else if (event instanceof DropColumnEvent) { | ||
| return DROP_COLUMN; | ||
| } else if (event instanceof RenameColumnEvent) { | ||
| return RENAME_COLUMN; | ||
| } else { | ||
| throw new RuntimeException("Unknown schema change event type: " + event.getClass()); | ||
yuxiqian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| public static SchemaChangeEventType ofTag(String tag) { | ||
| switch (tag) { | ||
| case "add.column": | ||
| return ADD_COLUMN; | ||
| case "alter.column.type": | ||
| return ALTER_COLUMN_TYPE; | ||
| case "create.table": | ||
| return CREATE_TABLE; | ||
| case "drop.column": | ||
| return DROP_COLUMN; | ||
| case "rename.column": | ||
| return RENAME_COLUMN; | ||
| default: | ||
| throw new RuntimeException("Unknown schema change event type: " + tag); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * 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.flink.cdc.common.event; | ||
|
|
||
| import org.apache.flink.cdc.common.annotation.PublicEvolving; | ||
|
|
||
| /** | ||
| * An enumeration of schema change event families for clustering {@link SchemaChangeEvent}s into | ||
| * categories. | ||
| */ | ||
| @PublicEvolving | ||
| public class SchemaChangeEventTypeFamily { | ||
|
|
||
| public static final SchemaChangeEventType[] ADD = {SchemaChangeEventType.ADD_COLUMN}; | ||
|
|
||
| public static final SchemaChangeEventType[] ALTER = {SchemaChangeEventType.ALTER_COLUMN_TYPE}; | ||
|
|
||
| public static final SchemaChangeEventType[] CREATE = {SchemaChangeEventType.CREATE_TABLE}; | ||
|
|
||
| public static final SchemaChangeEventType[] DROP = {SchemaChangeEventType.DROP_COLUMN}; | ||
|
|
||
| public static final SchemaChangeEventType[] RENAME = {SchemaChangeEventType.RENAME_COLUMN}; | ||
|
|
||
| public static final SchemaChangeEventType[] TABLE = {SchemaChangeEventType.CREATE_TABLE}; | ||
|
Comment on lines
+29
to
+39
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. Could you share the basis of the categories ? current hierarchy confuse me a bit.
Member
Author
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. For class names like |
||
|
|
||
| public static final SchemaChangeEventType[] COLUMN = { | ||
| SchemaChangeEventType.ADD_COLUMN, | ||
| SchemaChangeEventType.ALTER_COLUMN_TYPE, | ||
| SchemaChangeEventType.DROP_COLUMN, | ||
| SchemaChangeEventType.RENAME_COLUMN | ||
| }; | ||
|
|
||
| public static final SchemaChangeEventType[] ALL = { | ||
| SchemaChangeEventType.ADD_COLUMN, | ||
| SchemaChangeEventType.CREATE_TABLE, | ||
| SchemaChangeEventType.ALTER_COLUMN_TYPE, | ||
| SchemaChangeEventType.DROP_COLUMN, | ||
| SchemaChangeEventType.RENAME_COLUMN | ||
| }; | ||
|
|
||
| public static final SchemaChangeEventType[] NONE = {}; | ||
|
|
||
| public static SchemaChangeEventType[] ofTag(String tag) { | ||
| switch (tag) { | ||
| case "add": | ||
| return ADD; | ||
| case "alter": | ||
| return ALTER; | ||
| case "create": | ||
| return CREATE; | ||
| case "drop": | ||
| return DROP; | ||
| case "rename": | ||
| return RENAME; | ||
| case "table": | ||
| return TABLE; | ||
| case "column": | ||
| return COLUMN; | ||
| case "all": | ||
| return ALL; | ||
| default: | ||
| return NONE; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * 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.flink.cdc.common.exceptions; | ||
|
|
||
| import org.apache.flink.cdc.common.event.SchemaChangeEvent; | ||
| import org.apache.flink.util.FlinkRuntimeException; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| /** An exception occurred during schema evolution. */ | ||
| public class SchemaEvolveException extends FlinkRuntimeException { | ||
| private final SchemaChangeEvent applyingEvent; | ||
| private final String exceptionMessage; | ||
| private final @Nullable Throwable cause; | ||
|
|
||
| public SchemaEvolveException(SchemaChangeEvent applyingEvent, String exceptionMessage) { | ||
| this(applyingEvent, exceptionMessage, null); | ||
| } | ||
|
|
||
| public SchemaEvolveException( | ||
| SchemaChangeEvent applyingEvent, String exceptionMessage, @Nullable Throwable cause) { | ||
| super(cause); | ||
| this.applyingEvent = applyingEvent; | ||
| this.exceptionMessage = exceptionMessage; | ||
| this.cause = cause; | ||
| } | ||
|
|
||
| public SchemaChangeEvent getApplyingEvent() { | ||
| return applyingEvent; | ||
| } | ||
|
|
||
| public String getExceptionMessage() { | ||
| return exceptionMessage; | ||
| } | ||
|
|
||
| @Nullable | ||
| public Throwable getCause() { | ||
| return cause; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "SchemaEvolveException{" | ||
| + "applyingEvent=" | ||
| + applyingEvent | ||
| + ", exceptionMessage='" | ||
| + exceptionMessage | ||
| + '\'' | ||
| + ", cause='" | ||
| + cause | ||
| + '\'' | ||
| + '}'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * 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.flink.cdc.common.exceptions; | ||
|
|
||
| import org.apache.flink.cdc.common.event.SchemaChangeEvent; | ||
|
|
||
| /** A special kind of {@link SchemaEvolveException} that sink doesn't support such event type. */ | ||
| public class UnsupportedSchemaChangeEventException extends SchemaEvolveException { | ||
|
|
||
| public UnsupportedSchemaChangeEventException(SchemaChangeEvent applyingEvent) { | ||
| super(applyingEvent, "Sink doesn't support such schema change event.", null); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.