Skip to content

Commit

Permalink
Implement DB size estimation for DuckDB (#2742)
Browse files Browse the repository at this point in the history
* added EstimateSize in OLAPStore

* review changes
  • Loading branch information
rakeshsharma14317 committed Jul 5, 2023
1 parent 00130c2 commit 480ead7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runtime/drivers/druid/druid.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ func (c *connection) Migrate(ctx context.Context) (err error) {
func (c *connection) MigrationStatus(ctx context.Context) (current, desired int, err error) {
return 0, 0, nil
}

func (c *connection) EstimateSize() (int64, bool) {
return 0, false
}
13 changes: 13 additions & 0 deletions runtime/drivers/duckdb/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ func (c *connection) Ingest(ctx context.Context, env *connectors.Env, source *co
return summary, err
}

func (c *connection) EstimateSize() (int64, bool) {
var paths []string
path := c.config.DBFilePath
if path == "" {
return 0, true
}

// Add .wal file path (e.g final size will be sum of *.db and *.db.wal)
dbWalPath := fmt.Sprintf("%s.wal", path)
paths = append(paths, path, dbWalPath)
return fileSize(paths), true
}

func (c *connection) ingest(ctx context.Context, env *connectors.Env, source *connectors.Source) (*drivers.IngestionSummary, error) {
// Driver-specific overrides
if source.Connector == "local_file" {
Expand Down
4 changes: 4 additions & 0 deletions runtime/drivers/motherduck/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (c *connection) Ingest(ctx context.Context, env *connectors.Env, source *co
return summary, err
}

func (c *connection) EstimateSize() (int64, bool) {
return 0, false
}

func (c *connection) ingest(ctx context.Context, env *connectors.Env, source *connectors.Source) (*drivers.IngestionSummary, error) {
// Driver-specific overrides
if source.Connector == "local_file" {
Expand Down
1 change: 1 addition & 0 deletions runtime/drivers/olap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type OLAPStore interface {
Execute(ctx context.Context, stmt *Statement) (*Result, error)
Ingest(ctx context.Context, env *connectors.Env, source *connectors.Source) (*IngestionSummary, error)
InformationSchema() InformationSchema
EstimateSize() (int64, bool)
}

// Statement wraps a query to execute against an OLAP driver.
Expand Down

0 comments on commit 480ead7

Please sign in to comment.