liurenjie1024 commented on code in PR #19: URL: https://github.com/apache/iceberg-rust/pull/19#discussion_r1282702729
########## crates/iceberg/src/spec/schema.rs: ########## @@ -0,0 +1,111 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! This module defines schema in iceberg. + +use crate::spec::datatypes::{StructField, StructType}; + +const DEFAULT_SCHEMA_ID: i32 = 0; + +/// Defines schema in iceberg. +#[derive(Debug, PartialEq, Eq, Clone)] +pub struct Schema { + r#struct: StructType, + schema_id: i32, + highest_field_id: i32, +} + +/// Schema builder. +pub struct SchemaBuilder { + schema_id: i32, + fields: Vec<StructField>, +} + +impl SchemaBuilder { + /// Add fields to schem builder + pub fn with_fields(mut self, fields: impl IntoIterator<Item = StructField>) -> Self { + self.fields.extend(fields.into_iter()); + self + } + + /// Set schema id. + pub fn with_schema_id(mut self, schema_id: i32) -> Self { Review Comment: Yeah, in fact user don't need to call this method in builder, the default value is 0. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
