vernedeng commented on code in PR #123: URL: https://github.com/apache/flink-connector-pulsar/pull/123#discussion_r3295914163
########## flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/table/TableDataTypeUtils.java: ########## @@ -0,0 +1,98 @@ +/* + * 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.connector.pulsar.table; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.FieldsDataType; +import org.apache.flink.table.types.logical.LogicalType; +import org.apache.flink.table.types.logical.LogicalTypeRoot; +import org.apache.flink.table.types.logical.RowType; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +/** + * Utility methods for working with table {@link DataType}s. + * + * <p>This class contains methods that were removed from Flink's {@code DataTypeUtils} in Flink 2.x. + * They are copied here to maintain the connector's functionality. + */ +@Internal +public class TableDataTypeUtils { + + private TableDataTypeUtils() {} + + /** + * Removes a prefix from all field names in a row data type. + * + * @param dataType The row data type whose field names should be stripped. + * @param prefix The prefix to remove from each field name. + * @return A new data type with the prefix removed from field names. Review Comment: Added `TableDataTypeUtilsTest` covering: - `stripRowPrefix` with matching/non-matching prefixes - `stripRowPrefix` error on non-Row type - `renameRowFields` correctness and nullability preservation - `renameRowFields` error on field count mismatch -- 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]
