cube-js / cube-js/cube

`external_driver_factory` is unusable in Python (`cube.py`)

Open
#10,317 1 comment 0 reactions 1 assignee Claimed by @igorlukanin View on GitHub
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 10h
Merged PRs (30d)
203

Description

**Describe the bug**
When using `external_driver_factory` in Python configuration (`cube.py`), CubeJS does not convert the returned configuration dictionary to a driver instance. The function is called, but CubeJS expects a fully instantiated `BaseDriver` object with methods like `release(). It makes `external_driver_factory` effectively broken in Python.

**To Reproduce**
1. Create `cube.py` with `external_driver_factory` returning a config dict:

```python
from cube import config

@config("external_driver_factory")
def external_driver_factory(ctx: dict | None) -> dict:
return {
"type": "postgres",
"host": "localhost",
"port": 5432,
"database": "cube_external",
"user": "postgres",
"password": "secret",
}
```

2. Configure a primary driver with pre-aggregations enabled
3. Trigger a pre-aggregation build
4. See error:

```
TypeError: driver.release is not a function
at /cube/node_modules/@cubejs-backend/server-core/src/core/server.ts:671:30
```

**Expected behavior**
`external_driver_factory` in Python should accept configuration dictionaries and automatically convert them to driver instances, matching the behavior of `driver_factory`.

**Screenshots**
N/A

**Minimally reproducible Cube Schema**
N/A

**Version:**
latest

**Additional context**
Looks like `driverFactory` has conversion logic in `resolveDriver()`, but `externalDriverFactory` does not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.