amoro-format-mixed/amoro-mixed-spark/v3.2/amoro-mixed-spark-3.2/src/main/java/org/apache/amoro/spark/MixedFormatSparkCatalog.java [136:180]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private Schema checkAndConvertSchema(StructType schema, Map<String, String> properties) {
    Schema convertSchema;
    boolean useTimestampWithoutZoneInNewTables;
    SparkSession sparkSession = SparkSession.active();
    if (CatalogUtil.isMixedHiveCatalog(catalog)) {
      useTimestampWithoutZoneInNewTables = true;
    } else {
      useTimestampWithoutZoneInNewTables =
          Boolean.parseBoolean(
              sparkSession
                  .conf()
                  .get(
                      USE_TIMESTAMP_WITHOUT_TIME_ZONE_IN_NEW_TABLES,
                      USE_TIMESTAMP_WITHOUT_TIME_ZONE_IN_NEW_TABLES_DEFAULT));
    }
    if (useTimestampWithoutZoneInNewTables) {
      sparkSession.conf().set(HANDLE_TIMESTAMP_WITHOUT_TIMEZONE, true);
      convertSchema = SparkSchemaUtil.convert(schema, true);
    } else {
      convertSchema = SparkSchemaUtil.convert(schema, false);
    }

    // schema add primary keys
    if (properties.containsKey("primary.keys")) {
      PrimaryKeySpec primaryKeySpec =
          PrimaryKeySpec.fromDescription(convertSchema, properties.get("primary.keys"));
      List<String> primaryKeys = primaryKeySpec.fieldNames();
      Set<String> pkSet = new HashSet<>(primaryKeys);
      Set<Integer> identifierFieldIds = new HashSet<>();
      List<Types.NestedField> columnsWithPk = new ArrayList<>();
      convertSchema
          .columns()
          .forEach(
              nestedField -> {
                if (pkSet.contains(nestedField.name())) {
                  columnsWithPk.add(nestedField.asRequired());
                  identifierFieldIds.add(nestedField.fieldId());
                } else {
                  columnsWithPk.add(nestedField);
                }
              });
      return new Schema(columnsWithPk, identifierFieldIds);
    }
    return convertSchema;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/src/main/java/org/apache/amoro/spark/MixedFormatSparkCatalog.java [138:182]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private Schema checkAndConvertSchema(StructType schema, Map<String, String> properties) {
    Schema convertSchema;
    boolean useTimestampWithoutZoneInNewTables;
    SparkSession sparkSession = SparkSession.active();
    if (CatalogUtil.isMixedHiveCatalog(catalog)) {
      useTimestampWithoutZoneInNewTables = true;
    } else {
      useTimestampWithoutZoneInNewTables =
          Boolean.parseBoolean(
              sparkSession
                  .conf()
                  .get(
                      USE_TIMESTAMP_WITHOUT_TIME_ZONE_IN_NEW_TABLES,
                      USE_TIMESTAMP_WITHOUT_TIME_ZONE_IN_NEW_TABLES_DEFAULT));
    }
    if (useTimestampWithoutZoneInNewTables) {
      sparkSession.conf().set(HANDLE_TIMESTAMP_WITHOUT_TIMEZONE, true);
      convertSchema = SparkSchemaUtil.convert(schema, true);
    } else {
      convertSchema = SparkSchemaUtil.convert(schema, false);
    }

    // schema add primary keys
    if (properties.containsKey("primary.keys")) {
      PrimaryKeySpec primaryKeySpec =
          PrimaryKeySpec.fromDescription(convertSchema, properties.get("primary.keys"));
      List<String> primaryKeys = primaryKeySpec.fieldNames();
      Set<String> pkSet = new HashSet<>(primaryKeys);
      Set<Integer> identifierFieldIds = new HashSet<>();
      List<Types.NestedField> columnsWithPk = new ArrayList<>();
      convertSchema
          .columns()
          .forEach(
              nestedField -> {
                if (pkSet.contains(nestedField.name())) {
                  columnsWithPk.add(nestedField.asRequired());
                  identifierFieldIds.add(nestedField.fieldId());
                } else {
                  columnsWithPk.add(nestedField);
                }
              });
      return new Schema(columnsWithPk, identifierFieldIds);
    }
    return convertSchema;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



