slinkydeveloper commented on a change in pull request #17598: URL: https://github.com/apache/flink/pull/17598#discussion_r770609158
########## File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvSerDeSchemaFactory.java ########## @@ -0,0 +1,192 @@ +/* + * 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.formats.csv; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.serialization.DeserializationSchema; +import org.apache.flink.api.common.serialization.SerializationSchema; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.configuration.ConfigOption; +import org.apache.flink.configuration.ReadableConfig; +import org.apache.flink.table.connector.ChangelogMode; +import org.apache.flink.table.connector.format.DecodingFormat; +import org.apache.flink.table.connector.format.EncodingFormat; +import org.apache.flink.table.connector.sink.DynamicTableSink; +import org.apache.flink.table.connector.source.DynamicTableSource; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.factories.DeserializationFormatFactory; +import org.apache.flink.table.factories.DynamicTableFactory; +import org.apache.flink.table.factories.FactoryUtil; +import org.apache.flink.table.factories.SerializationFormatFactory; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.logical.RowType; + +import org.apache.commons.lang3.StringEscapeUtils; + +import java.util.Collections; +import java.util.Set; + +import static org.apache.flink.formats.csv.CsvFormatOptions.ALLOW_COMMENTS; +import static org.apache.flink.formats.csv.CsvFormatOptions.ARRAY_ELEMENT_DELIMITER; +import static org.apache.flink.formats.csv.CsvFormatOptions.DISABLE_QUOTE_CHARACTER; +import static org.apache.flink.formats.csv.CsvFormatOptions.ESCAPE_CHARACTER; +import static org.apache.flink.formats.csv.CsvFormatOptions.FIELD_DELIMITER; +import static org.apache.flink.formats.csv.CsvFormatOptions.IGNORE_PARSE_ERRORS; +import static org.apache.flink.formats.csv.CsvFormatOptions.NULL_LITERAL; +import static org.apache.flink.formats.csv.CsvFormatOptions.QUOTE_CHARACTER; + +/** + * Format factory for providing configured instances of CSV to RowData {@link SerializationSchema} + * and {@link DeserializationSchema}. + */ +@Internal +public final class CsvSerDeSchemaFactory + implements DeserializationFormatFactory, SerializationFormatFactory { + + @Override + public DecodingFormat<DeserializationSchema<RowData>> createDecodingFormat( + DynamicTableFactory.Context context, ReadableConfig formatOptions) { + FactoryUtil.validateFactoryOptions(this, formatOptions); + CsvCommons.validateFormatOptions(formatOptions); + + return new DecodingFormat<DeserializationSchema<RowData>>() { + @Override + public DeserializationSchema<RowData> createRuntimeDecoder( Review comment: @AHeise But then why `CsvFormatFactory` returns a `ProjectableDecodingFormat`? It doesn't make sense, becuse either none of them are projectable or both are. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org