static String getKeyGeneratorClass()

in xtable-core/src/main/java/org/apache/xtable/hudi/HudiTableManager.java [127:160]


  static String getKeyGeneratorClass(
      List<InternalPartitionField> partitionFields, List<InternalField> recordKeyFields) {
    if (partitionFields.stream()
        .anyMatch(
            internalPartitionField ->
                internalPartitionField.getTransformType() == PartitionTransformType.BUCKET)) {
      throw new PartitionSpecException("Bucket partition is not yet supported by Hudi targets");
    }
    boolean multipleRecordKeyFields = recordKeyFields.size() > 1;
    boolean multiplePartitionFields = partitionFields.size() > 1;
    String keyGeneratorClass;
    if (partitionFields.isEmpty()) {
      keyGeneratorClass = NONPARTITIONED_KEY_GENERATOR;
    } else {
      if (partitionFields.stream()
          .anyMatch(partitionField -> partitionField.getTransformType().isTimeBased())) {
        if (multiplePartitionFields) {
          // if there is more than one partition field and one of them is a date, we need to use
          // CustomKeyGenerator
          keyGeneratorClass = CUSTOM_KEY_GENERATOR;
        } else {
          // if there is only one partition field and it is a date, we can use
          // TimestampBasedKeyGenerator
          keyGeneratorClass = TIMESTAMP_BASED_KEY_GENERATOR;
        }
      } else {
        keyGeneratorClass =
            multipleRecordKeyFields || multiplePartitionFields
                ? COMPLEX_KEY_GENERATOR
                : SIMPLE_KEY_GENERATOR;
      }
    }
    return keyGeneratorClass;
  }