haruki-830 commented on code in PR #4540: URL: https://github.com/apache/flink-cdc/pull/4540#discussion_r4024844209
########## flink-cdc-common/src/main/java/org/apache/flink/cdc/common/sink/ExistingTableSchemaExpansionSupport.java: ########## @@ -0,0 +1,53 @@ +/* + * 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.sink; + +import org.apache.flink.cdc.common.annotation.Experimental; +import org.apache.flink.cdc.common.event.TableId; +import org.apache.flink.cdc.common.exceptions.SchemaEvolveException; +import org.apache.flink.cdc.common.schema.Schema; +import org.apache.flink.cdc.common.types.DataType; + +import java.io.Serializable; +import java.util.Optional; + +/** Connector-specific capabilities required to safely expand an existing target table schema. */ +@Experimental +public interface ExistingTableSchemaExpansionSupport extends Serializable { + + /** + * Returns the current schema of the target table, or {@link Optional#empty()} if the table does + * not exist. Target physical types must be converted to the same canonical CDC representation + * produced by {@link #normalizeToTargetDataType(TableId, String, DataType)}. + */ + Optional<Schema> getExistingTableSchema(TableId tableId) throws SchemaEvolveException; + + /** + * Converts a pipeline type to the canonical CDC representation of the physical type that this + * applier will create in the target system. For example, if both {@code CHAR(n)} and {@code + * VARCHAR(n)} map to target {@code VARCHAR(n)}, this method should return the same {@code + * VARCHAR(n)} representation for both input types. + * + * <p>This method must not query or modify the target table. + */ + DataType normalizeToTargetDataType( Review Comment: Thanks for the suggestion! I’ve added the existing target schema as a parameter to normalizeToTargetDataType. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
