Skip to content

Commit

Permalink
Fix loading tables with a relative Iceberg path on a local disk
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Nov 8, 2024
1 parent 27e1c2a commit c2dc85d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
13 changes: 7 additions & 6 deletions scripts/build-darwin.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
go build -C src -o ../build/bemidb-darwin-arm64

LIBCPP_PATH=$(otool -L ./build/bemidb-darwin-arm64 | grep -o '/.*/libc++\.1\.0\.dylib')
sudo cp $LIBCPP_PATH ./build/libc++.1.0.dylib
cd src
go build -o ../build/bemidb-darwin-arm64

cd ../build
LIBCPP_PATH=$(otool -L ./bemidb-darwin-arm64 | grep -o '/.*/libc++\.1\.0\.dylib')
sudo cp $LIBCPP_PATH ./libc++.1.0.dylib
sudo cp $LIBCPP_PATH /usr/local/lib/libc++.1.0.dylib
install_name_tool -change $LIBCPP_PATH /usr/local/lib/libc++.1.0.dylib ./build/bemidb-darwin-arm64
otool -L ./build/bemidb-darwin-arm64
install_name_tool -change $LIBCPP_PATH /usr/local/lib/libc++.1.0.dylib ./bemidb-darwin-arm64
otool -L ./bemidb-darwin-arm64
19 changes: 6 additions & 13 deletions src/storage_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"

"github.com/google/uuid"
"github.com/xitongsys/parquet-go-source/local"
Expand All @@ -26,12 +25,9 @@ func (storage *StorageLocal) IcebergMetadataFilePath(schemaTable SchemaTable) st
}

func (storage *StorageLocal) IcebergSchemaTables() (schemaTables []SchemaTable, err error) {
_, sourceFilePath, _, ok := runtime.Caller(0)
if !ok {
panic("Failed to get source file path")
}
projectDir := filepath.Dir(sourceFilePath)
schemasPath := filepath.Join(projectDir, storage.config.IcebergPath)
execPath, err := os.Getwd()
PanicIfError(err)
schemasPath := filepath.Join(execPath, storage.config.IcebergPath)

schemas, err := storage.nestedDirectories(schemasPath)
if err != nil {
Expand Down Expand Up @@ -176,12 +172,9 @@ func (storage *StorageLocal) CreateVersionHint(metadataDirPath string, metadataF
}

func (storage *StorageLocal) tablePath(schemaTable SchemaTable) string {
_, sourceFilePath, _, ok := runtime.Caller(0)
if !ok {
panic("Failed to get source file path")
}
projectDir := filepath.Dir(sourceFilePath)
return filepath.Join(projectDir, storage.config.IcebergPath, schemaTable.Schema, schemaTable.Table)
execPath, err := os.Getwd()
PanicIfError(err)
return filepath.Join(execPath, storage.config.IcebergPath, schemaTable.Schema, schemaTable.Table)
}

func (storage *StorageLocal) fileSystemPrefix() string {
Expand Down

0 comments on commit c2dc85d

Please sign in to comment.