lirui-apache commented on a change in pull request #13939:
URL: https://github.com/apache/flink/pull/13939#discussion_r518573163



##########
File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/read/HiveBulkFormatAdapter.java
##########
@@ -107,24 +114,78 @@ public boolean isSplittable() {
                return InternalTypeInfo.of(producedRowType);
        }
 
+       private RowType tableRowType() {
+               LogicalType[] types = 
Arrays.stream(fieldTypes).map(DataType::getLogicalType).toArray(LogicalType[]::new);
+               return RowType.of(types, fieldNames);
+       }
+
+       private int[] projectedFields() {

Review comment:
       We already have a `computeSelectedFields` method, can it be reused?

##########
File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/connectors/hive/read/HiveBulkFormatAdapter.java
##########
@@ -107,24 +114,78 @@ public boolean isSplittable() {
                return InternalTypeInfo.of(producedRowType);
        }
 
+       private RowType tableRowType() {
+               LogicalType[] types = 
Arrays.stream(fieldTypes).map(DataType::getLogicalType).toArray(LogicalType[]::new);
+               return RowType.of(types, fieldNames);
+       }
+
+       private int[] projectedFields() {
+               List<String> nameList = Arrays.asList(fieldNames);
+               int[] projectedFields = new 
int[producedRowType.getFieldCount()];
+               List<String> projectedNames = producedRowType.getFieldNames();
+               for (int i = 0; i < projectedFields.length; i++) {
+                       projectedFields[i] = 
nameList.indexOf(projectedNames.get(i));
+               }
+               return projectedFields;
+       }
+
        private BulkFormat<RowData, ? super HiveSourceSplit> 
createBulkFormatForSplit(HiveSourceSplit split) {
                if (!useMapRedReader && 
useParquetVectorizedRead(split.getHiveTablePartition())) {
-                       PartitionFieldExtractor<HiveSourceSplit> extractor = 
(PartitionFieldExtractor<HiveSourceSplit>)
-                                       (split1, fieldName, fieldType) -> 
split1.getHiveTablePartition().getPartitionSpec().get(fieldName);
                        return 
ParquetColumnarRowInputFormat.createPartitionedFormat(
                                        jobConfWrapper.conf(),
                                        producedRowType,
                                        partitionKeys,
-                                       extractor,
+                                       PARTITION_FIELD_EXTRACTOR,
                                        DEFAULT_SIZE,
                                        hiveVersion.startsWith("3"),
                                        false
                        );
+               } else if (!useMapRedReader && 
useOrcVectorizedRead(split.getHiveTablePartition())) {
+                       return createOrcFormat();
                } else {
                        return new HiveMapRedBulkFormat();
                }
        }
 
+       private OrcColumnarRowFileInputFormat<?, HiveSourceSplit> 
createOrcFormat() {
+               return hiveVersion.startsWith("1.") ?
+                               
OrcColumnarRowFileInputFormat.createPartitionedFormat(
+                                       OrcShim.createShim(hiveVersion),
+                                       jobConfWrapper.conf(),
+                                       tableRowType(),
+                                       partitionKeys,
+                                       PARTITION_FIELD_EXTRACTOR,
+                                       projectedFields(),
+                                       new ArrayList<>(),

Review comment:
       `Collections.emptyList()`?




----------------------------------------------------------------
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


Reply via email to