cube-js / cube-js/cube

Multi Query will cause create two duckdb driver

Open
#7,581 2 comments 0 reactions 1 assignee Claimed by @ovr View on GitHub
question
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
I build a new image from cubejs/cube:v0.33.61, and fork duckdb driver:https://github.com/cube-js/cube/tree/v0.34.40/packages/cubejs-duckdb-driver, add log on the init function.
When i send post query, the querytype is multi, There are two records about init,i think the dirver's constructor has called twice,and created to duckdb instance.

**To Reproduce**
Steps to reproduce the behavior:
1. Frok duckdb' project to repo and name it "customize-duckdb-cubejs-driver" , add log in constructor and init function
![image](https://github.com/cube-js/cube/assets/8774179/1d27b87a-51b6-4276-a972-77ff118031ce)

3. Build New Image:

- Dockfile
`
FROM cubejs/cube:v0.34.40
RUN apt-get update && apt-get install -y git
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
RUN mkdir -p node_modules
COPY package.json .
COPY cube.js .
COPY schema ./schema
RUN --mount=type=ssh npm install

`

- the package.json that dependencies the repo of step1
`
{
...
"dependencies": {
"customize-duckdb-cubejs-driver": "bitbucket:test/customize-duckdb-cubejs-driver"
}
...
}
`


5. start cube service

- docker-compose.file
![image](https://github.com/cube-js/cube/assets/8774179/a53459d9-3f97-47a8-93c5-900479790ec9)

7. Send Multi Query
`{
"query": {
"measures": [
"test.currency",
],
"dimensions": [
"test.local_book_date"
],
"timeDimensions": [{
"dimension": "test.local_book_date",
"compareDateRange": [["2023-06-01","2023-07-31"], ["2023-08-01","2043-12-11"]]
}
]
},
"queryType":"multi"
}`

The driver and db instance are init twice, the related log
`
taihu-cube-pc-cube_api-1 | create duckdb driver
taihu-cube-pc-cube_api-1 | create duckdb driver
.....
taihu-cube-pc-cube_api-1 | init duckdb
taihu-cube-pc-cube_api-1 | init duckdb

`
**Expected behavior**
The Driver and db are init once.

**Version:**
v0.33.61 and v.34.40

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.