You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "liurenjie1024 (via GitHub)" <gi...@apache.org> on 2023/09/08 11:27:32 UTC

[GitHub] [iceberg-rust] liurenjie1024 commented on a diff in pull request #57: Metadata integration tests

liurenjie1024 commented on code in PR #57:
URL: https://github.com/apache/iceberg-rust/pull/57#discussion_r1319737798


##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -346,21 +349,29 @@ pub(super) mod _serde {
             } else {
                 value.current_snapshot_id
             };
+            let schemas = HashMap::from_iter(
+                value
+                    .schemas
+                    .into_iter()
+                    .map(|schema| Ok((schema.schema_id, Arc::new(schema.try_into()?))))
+                    .collect::<Result<Vec<_>, Error>>()?,
+            );
             Ok(TableMetadata {
                 format_version: FormatVersion::V2,
                 table_uuid: value.table_uuid,
                 location: value.location,
                 last_sequence_number: value.last_sequence_number,
                 last_updated_ms: value.last_updated_ms,
                 last_column_id: value.last_column_id,
-                schemas: HashMap::from_iter(
-                    value
-                        .schemas
-                        .into_iter()
-                        .map(|schema| Ok((schema.schema_id, Arc::new(schema.try_into()?))))
-                        .collect::<Result<Vec<_>, Error>>()?,
-                ),
-                current_schema_id: value.current_schema_id,
+                current_schema_id: if schemas.keys().contains(&value.current_schema_id) {
+                    Ok(value.current_schema_id)
+                } else {
+                    Err(self::Error::new(
+                        ErrorKind::DataInvalid,
+                        "No schema exists with the current schema id.",

Review Comment:
   ```suggestion
                           format!("No schema exists with the current schema id: {}", *value.current_schema_id),
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org