codope commented on a change in pull request #4203: URL: https://github.com/apache/hudi/pull/4203#discussion_r779645642
########## File path: hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestTimestampBasedKeyGenerator.java ########## @@ -238,6 +238,40 @@ public void testScalar() throws IOException { assertEquals("2021-04-19", keyGen.getPartitionPath(baseRow)); } + @Test + public void testScalarWithLogicalType() throws IOException { + schema = SchemaTestUtil.getTimestampWithLogicalTypeSchema(); + structType = AvroConversionUtils.convertAvroSchemaToStructType(schema); + baseRecord = SchemaTestUtil.generateAvroRecordFromJson(schema, 1, "001", "f1"); + baseRecord.put("createTime", 1638513806000000L); + + properties = getBaseKeyConfig("SCALAR", "yyyy/MM/dd", "GMT", "MICROSECONDS"); + properties.setProperty(KeyGeneratorOptions.KEYGENERATOR_CONSISTENT_LOGICAL_TIMESTAMP_ENABLED.key(), "true"); + TimestampBasedKeyGenerator keyGen = new TimestampBasedKeyGenerator(properties); + HoodieKey hk1 = keyGen.getKey(baseRecord); + assertEquals("2021/12/03", hk1.getPartitionPath()); + + // test w/ Row + baseRow = genericRecordToRow(baseRecord); + assertEquals("2021/12/03", keyGen.getPartitionPath(baseRow)); + internalRow = KeyGeneratorTestUtilities.getInternalRow(baseRow); + assertEquals("2021/12/03", keyGen.getPartitionPath(internalRow, baseRow.schema())); Review comment: If config is not set then it throws an exception `HoodieKeyGeneratorException: Unable to parse input partition field` -- 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