nsivabalan commented on a change in pull request #3247: URL: https://github.com/apache/hudi/pull/3247#discussion_r671356705
########## File path: hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/BuiltinKeyGenerator.java ########## @@ -81,7 +105,52 @@ public String getPartitionPath(Row row) { return getKey(genericRecord).getPartitionPath(); } - void buildFieldPositionMapIfNeeded(StructType structType) { + /** + * Fetch partition path from {@link InternalRow}. + * + * @param internalRow {@link InternalRow} instance from which partition path needs to be fetched from. + * @param structType schema of the internalRow. + * @return the partition path. + */ + public String getPartitionPath(InternalRow internalRow, StructType structType) { + try { + Row row = deserializeRow(getEncoder(structType), internalRow); + return getPartitionPath(row); + } catch (Exception e) { + throw new HoodieIOException("Conversion of InternalRow to Row failed with exception " + e); + } + } + + private ExpressionEncoder getEncoder(StructType structType) { + if (encoder == null) { + encoder = getRowEncoder(structType); + } + return encoder; + } + + private static ExpressionEncoder getRowEncoder(StructType schema) { + List<Attribute> attributes = JavaConversions.asJavaCollection(schema.toAttributes()).stream() + .map(Attribute::toAttribute).collect(Collectors.toList()); + return RowEncoder.apply(schema) Review comment: yes. -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org