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 fac7bf5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Bump DuckDB version to 1.1.3
- Compile the binary for arm64 MacOS with linked libc++
- Fix loading tables with a relative Iceberg path on a local disk

### v0.1.0 - 2024-11-06

Expand Down
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 fac7bf5

Please sign in to comment.