@@ -519,7 +519,8 @@ Result<std::unique_ptr<PartitionField>> PartitionFieldFromJson(
519519 std::move (transform));
520520}
521521
522- Result<std::unique_ptr<PartitionSpec>> PartitionSpecFromJson (const nlohmann::json& json) {
522+ Result<std::unique_ptr<PartitionSpec>> PartitionSpecFromJson (
523+ const std::shared_ptr<Schema>& schema, const nlohmann::json& json) {
523524 ICEBERG_ASSIGN_OR_RAISE (auto spec_id, GetJsonValue<int32_t >(json, kSpecId ));
524525 ICEBERG_ASSIGN_OR_RAISE (auto fields, GetJsonValue<nlohmann::json>(json, kFields ));
525526
@@ -528,6 +529,8 @@ Result<std::unique_ptr<PartitionSpec>> PartitionSpecFromJson(const nlohmann::jso
528529 ICEBERG_ASSIGN_OR_RAISE (auto partition_field, PartitionFieldFromJson (field_json));
529530 partition_fields.push_back (std::move (*partition_field));
530531 }
532+ // TODO(Li Feiyang):use a new PartitionSpec::Make to find the source field of each
533+ // partition field from schema and then verify it
531534 return std::make_unique<PartitionSpec>(spec_id, std::move (partition_fields));
532535}
533536
@@ -855,6 +858,7 @@ Result<std::shared_ptr<Schema>> ParseSchemas(
855858// / \param[out] default_spec_id The default partition spec ID.
856859// / \param[out] partition_specs The list of partition specs.
857860Status ParsePartitionSpecs (const nlohmann::json& json, int8_t format_version,
861+ const std::shared_ptr<Schema>& current_schema,
858862 int32_t & default_spec_id,
859863 std::vector<std::shared_ptr<PartitionSpec>>& partition_specs) {
860864 if (json.contains (kPartitionSpecs )) {
@@ -867,7 +871,8 @@ Status ParsePartitionSpecs(const nlohmann::json& json, int8_t format_version,
867871 ICEBERG_ASSIGN_OR_RAISE (default_spec_id, GetJsonValue<int32_t >(json, kDefaultSpecId ));
868872
869873 for (const auto & spec_json : spec_array) {
870- ICEBERG_ASSIGN_OR_RAISE (auto spec, PartitionSpecFromJson (spec_json));
874+ ICEBERG_ASSIGN_OR_RAISE (auto spec,
875+ PartitionSpecFromJson (current_schema, spec_json));
871876 partition_specs.push_back (std::move (spec));
872877 }
873878 } else {
@@ -973,9 +978,9 @@ Result<std::unique_ptr<TableMetadata>> TableMetadataFromJson(const nlohmann::jso
973978 ParseSchemas (json, table_metadata->format_version ,
974979 table_metadata->current_schema_id , table_metadata->schemas ));
975980
976- ICEBERG_RETURN_UNEXPECTED (ParsePartitionSpecs (json, table_metadata-> format_version ,
977- table_metadata->default_spec_id ,
978- table_metadata->partition_specs ));
981+ ICEBERG_RETURN_UNEXPECTED (ParsePartitionSpecs (
982+ json, table_metadata->format_version , current_schema ,
983+ table_metadata-> default_spec_id , table_metadata->partition_specs ));
979984
980985 if (json.contains (kLastPartitionId )) {
981986 ICEBERG_ASSIGN_OR_RAISE (table_metadata->last_partition_id ,
0 commit comments