[GitHub] [flink] JingsongLi commented on a change in pull request #12206: [FLINK-14255][hive] Integrate hive to streaming file sink with parquet and orc
JingsongLi commented on a change in pull request #12206: URL: https://github.com/apache/flink/pull/12206#discussion_r426350492 ## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShim.java ## @@ -205,4 +208,10 @@ SimpleGenericUDAFParameterInfo createUDAFParameterInfo(ObjectInspector[] params, */ void createTableWithConstraints(IMetaStoreClient client, Table table, Configuration conf, UniqueConstraint pk, List pkTraits, List notNullCols, List nnTraits); + + /** +* Create orc {@link BulkWriter.Factory} for different hive versions. +*/ + BulkWriter.Factory createOrcBulkWriterFactory( Review comment: I created a orc shim improvement: https://issues.apache.org/jira/browse/FLINK-17785 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [flink] JingsongLi commented on a change in pull request #12206: [FLINK-14255][hive] Integrate hive to streaming file sink with parquet and orc
JingsongLi commented on a change in pull request #12206: URL: https://github.com/apache/flink/pull/12206#discussion_r426350298 ## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/HiveTableSink.java ## @@ -143,21 +206,51 @@ public HiveTableSink(JobConf jobConf, ObjectPath tablePath, CatalogTable table) } } - @Override - public TableSink configure(String[] fieldNames, TypeInformation[] fieldTypes) { - return new HiveTableSink(jobConf, tablePath, catalogTable); + private BulkWriter.Factory createBulkWriterFactory(String[] partitionColumns, + StorageDescriptor sd) { + String serLib = sd.getSerdeInfo().getSerializationLib().toLowerCase(); + int formatFieldCount = tableSchema.getFieldCount() - partitionColumns.length; + String[] formatNames = new String[formatFieldCount]; + LogicalType[] formatTypes = new LogicalType[formatFieldCount]; + for (int i = 0; i < formatFieldCount; i++) { + formatNames[i] = tableSchema.getFieldName(i).get(); + formatTypes[i] = tableSchema.getFieldDataType(i).get().getLogicalType(); + } + RowType formatType = RowType.of(formatTypes, formatNames); + Configuration formatConf = new Configuration(jobConf); + sd.getSerdeInfo().getParameters().forEach(formatConf::set); + BulkWriter.Factory bulkFactory; + if (serLib.contains("parquet")) { Review comment: I created a JIRA for this refactor: https://issues.apache.org/jira/browse/FLINK-17784 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [flink] JingsongLi commented on a change in pull request #12206: [FLINK-14255][hive] Integrate hive to streaming file sink with parquet and orc
JingsongLi commented on a change in pull request #12206: URL: https://github.com/apache/flink/pull/12206#discussion_r426348785 ## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShim.java ## @@ -205,4 +208,10 @@ SimpleGenericUDAFParameterInfo createUDAFParameterInfo(ObjectInspector[] params, */ void createTableWithConstraints(IMetaStoreClient client, Table table, Configuration conf, UniqueConstraint pk, List pkTraits, List notNullCols, List nnTraits); + + /** +* Create orc {@link BulkWriter.Factory} for different hive versions. +*/ + BulkWriter.Factory createOrcBulkWriterFactory( Review comment: I think this is hive shim, because orc factory is related to hive version. If not this, will be a ugly `if else`. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [flink] JingsongLi commented on a change in pull request #12206: [FLINK-14255][hive] Integrate hive to streaming file sink with parquet and orc
JingsongLi commented on a change in pull request #12206: URL: https://github.com/apache/flink/pull/12206#discussion_r426348623 ## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/write/HiveOutputFormatFactory.java ## @@ -0,0 +1,81 @@ +/* + * 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.connectors.hive.write; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.core.fs.Path; +import org.apache.flink.runtime.fs.hdfs.HadoopFileSystem; +import org.apache.flink.table.filesystem.OutputFormatFactory; +import org.apache.flink.types.Row; + +import org.apache.hadoop.hive.ql.exec.FileSinkOperator.RecordWriter; +import org.apache.hadoop.io.Writable; + +import java.io.IOException; +import java.util.function.Function; + +/** + * Hive {@link OutputFormatFactory}, use {@link RecordWriter} to write record. + */ +public class HiveOutputFormatFactory implements OutputFormatFactory { Review comment: I will delete old one to extract `RecordWriterFactory`. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org