@Test public void testScalar() throws IOException { baseRecord.put("createTime", 20000L); properties = getBaseKeyConfig("SCALAR", "yyyy-MM-dd hh", "GMT", "days"); TimestampBasedKeyGenerator keyGen = new TimestampBasedKeyGenerator(properties); HoodieKey hk1 = keyGen.getKey(baseRecord); assertEquals(hk1.getPartitionPath(), "2024-10-04 12"); baseRow = genericRecordToRow(baseRecord); assertEquals("2024-10-04 12", keyGen.getPartitionPath(baseRow)); baseRecord.put("createTime", null); properties = getBaseKeyConfig("SCALAR", "yyyy-MM-dd hh", "GMT", "days"); keyGen = new TimestampBasedKeyGenerator(properties); HoodieKey hk2 = keyGen.getKey(baseRecord); assertEquals("1970-01-02 12", hk2.getPartitionPath()); baseRow = genericRecordToRow(baseRecord); assertEquals("1970-01-02 12", keyGen.getPartitionPath(baseRow)); }
@Override public String getPartitionPath(GenericRecord record) { Object partitionVal = HoodieAvroUtils.getNestedFieldVal(record, getPartitionPathFields().get(0), true); if (partitionVal == null) { partitionVal = getDefaultPartitionVal(); } try { return getPartitionPath(partitionVal); } catch (Exception e) { throw new HoodieDeltaStreamerException("Unable to parse input partition field :" + partitionVal, e); } }
TimestampBasedKeyGenerator extends SimpleKeyGenerator { @Override public String getPartitionPath(GenericRecord record) { Object partitionVal = HoodieAvroUtils.getNestedFieldVal(record, getPartitionPathFields().get(0), true); if (partitionVal == null) { partitionVal = getDefaultPartitionVal(); } try { return getPartitionPath(partitionVal); } catch (Exception e) { throw new HoodieDeltaStreamerException("Unable to parse input partition field :" + partitionVal, e); } } }
TimestampBasedKeyGenerator extends SimpleKeyGenerator { @Override public String getPartitionPath(GenericRecord record) { Object partitionVal = HoodieAvroUtils.getNestedFieldVal(record, getPartitionPathFields().get(0), true); if (partitionVal == null) { partitionVal = getDefaultPartitionVal(); } try { return getPartitionPath(partitionVal); } catch (Exception e) { throw new HoodieDeltaStreamerException("Unable to parse input partition field :" + partitionVal, e); } } TimestampBasedKeyGenerator(TypedProperties config);   TimestampBasedKeyGenerator(TypedProperties config, String partitionPathField);   TimestampBasedKeyGenerator(TypedProperties config, String recordKeyField, String partitionPathField); }
TimestampBasedKeyGenerator extends SimpleKeyGenerator { @Override public String getPartitionPath(GenericRecord record) { Object partitionVal = HoodieAvroUtils.getNestedFieldVal(record, getPartitionPathFields().get(0), true); if (partitionVal == null) { partitionVal = getDefaultPartitionVal(); } try { return getPartitionPath(partitionVal); } catch (Exception e) { throw new HoodieDeltaStreamerException("Unable to parse input partition field :" + partitionVal, e); } } TimestampBasedKeyGenerator(TypedProperties config);   TimestampBasedKeyGenerator(TypedProperties config, String partitionPathField);   TimestampBasedKeyGenerator(TypedProperties config, String recordKeyField, String partitionPathField); @Override String getPartitionPath(GenericRecord record); @Override String getRecordKey(Row row); @Override String getPartitionPath(Row row); }
TimestampBasedKeyGenerator extends SimpleKeyGenerator { @Override public String getPartitionPath(GenericRecord record) { Object partitionVal = HoodieAvroUtils.getNestedFieldVal(record, getPartitionPathFields().get(0), true); if (partitionVal == null) { partitionVal = getDefaultPartitionVal(); } try { return getPartitionPath(partitionVal); } catch (Exception e) { throw new HoodieDeltaStreamerException("Unable to parse input partition field :" + partitionVal, e); } } TimestampBasedKeyGenerator(TypedProperties config);   TimestampBasedKeyGenerator(TypedProperties config, String partitionPathField);   TimestampBasedKeyGenerator(TypedProperties config, String recordKeyField, String partitionPathField); @Override String getPartitionPath(GenericRecord record); @Override String getRecordKey(Row row); @Override String getPartitionPath(Row row);  }