tanmayrauth commented on code in PR #1158: URL: https://github.com/apache/iceberg-go/pull/1158#discussion_r3353905699
########## catalog/hadoop/io.go: ########## @@ -0,0 +1,100 @@ +// 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 hadoop + +import ( + "io/fs" + + icebergio "github.com/apache/iceberg-go/io" +) + +// HadoopCatalogFS represents all the interfaces that a filesystem implementation +// must satisfy to be used for a Hadoop catalog implementation. +type HadoopCatalogFS interface { + icebergio.ListableIO + icebergio.ReadFileIO + icebergio.WriteFileIO + StatIO + RenameIO + RemoveAllIO + MkdirAllIO + MkdirIO + ReadDirIO +} + +// Ensure that the LocalFS implements the extensions +// thus ensuring that the hadoop catalog can use the LocalFS for its +// IO operations +var ( + _ icebergio.IO = (*icebergio.LocalFS)(nil) + _ StatIO = (*icebergio.LocalFS)(nil) + _ RenameIO = (*icebergio.LocalFS)(nil) + _ RemoveAllIO = (*icebergio.LocalFS)(nil) + _ MkdirIO = (*icebergio.LocalFS)(nil) + _ MkdirAllIO = (*icebergio.LocalFS)(nil) Review Comment: LocalFS.WriteFile mode should be 0o644, not 0o755. Your PR description explains the 0o777 → 0o755 change as removing the execute bit, but WriteFile's third arg is a file mode where 0o755 still grants +x to everyone. The hadoop catalog used to write the version-hint file with explicit 0o644 at hadoop.go (pre-PR line 232); after this PR it goes through LocalFS.WriteFile and inherits 0o755, so the version-hint file is now created executable. 0o755 is correct for the directory cases (Mkdir/MkdirAll), just not for WriteFile. ########## catalog/hadoop/hadoop.go: ########## @@ -354,13 +357,13 @@ func (c *Catalog) CreateTable(ctx context.Context, ident table.Identifier, sc *i } if err := internal.WriteTableMetadata(metadata, icebergio.LocalFS{}, tempPath, compression); err != nil { Review Comment: pass `c.filesystem` to `WriteTableMetadata`, not `icebergio.LocalFS{}`.** `HadoopCatalogFS` embeds `WriteFileIO`, so `c.filesystem` already satisfies the parameter. Today both resolve to the same value via the hardcoded constructor, but the whole point of this PR is that `c.filesystem` can later be swapped — leaving those two call sites pinned to `LocalFS{}` means the eventual cloud-backed catalog would write metadata to local disk while the surrounding rename/cleanup goes to the cloud FS. Worth fixing in this PR so the abstraction is fully wired. -- 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]
