ferhatelmas commented on code in PR #692: URL: https://github.com/apache/iceberg-go/pull/692#discussion_r2738538155
########## table/utils.go: ########## @@ -0,0 +1,36 @@ +// 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. + +package table + +import ( + "fmt" + "slices" + + "github.com/apache/iceberg-go" +) + +func getPartitionSpecByID(specs []iceberg.PartitionSpec, specID int) (*iceberg.PartitionSpec, error) { + i := slices.IndexFunc(specs, func(spec iceberg.PartitionSpec) bool { + return spec.ID() == specID + }) + if i < 0 { + return nil, fmt.Errorf("%w: id %d", ErrPartitionSpecNotFound, specID) + } + + return &specs[i], nil Review Comment: It has reference type fields (slice) so copy isn't deep. I don't see any updates but only reads which might not make a difference either way in the existing code. However, pointer signals to me that I am getting the actual reference. It's not the case here, it could be misleading. That being said, similar pattern exists for `Snapshot`, `SortOrder` and `Schema`. Only schema is clear because it is a list of pointers. Others are doing copy (value -> pointer -> value). We might want to address all of them at once for consistency. For now, ref to copy is fine I believe to align with existing code. cc @zeroshade -- 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]
