Closed cemhany closed 1 week ago
Hi @cemhany 👋
According to the docs, driver_factory
is called (at least) once per data_source
for every orchestrator id.
First of all, you probably need to define context_to_orchestrator_id
if you'd like to provide different driver instances to different tenants of your app.
Second, I wasn't able to reproduce this. I see that sql
triggers driver_factory
both for the default
and "custom" data source.
Here's my config:
module.exports = {
driverFactory: (context) => {
console.log(``)
console.log(`Security context: ${JSON.stringify(context.securityContext)}`)
console.log(`Data source: ${context.dataSource}`)
return {
type: 'duckdb'
}
},
contextToOrchestratorId: (context) => {
return `${context.securityContext.name}`;
}
}
Here's my console command:
curl \
-H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ._XEngvIuxOcA-j7y_upRUbXli4DLToNf7HxH1XNmxSc" \
-G \
--data-urlencode 'query={"measures":["data_source_foo.count"]}' \
https://remaining-powersville.gcp-us-central1.cubecloudapp.dev/user/igor%40cube.dev/13/cubejs-api/v1/sql
Here's what I see in the logs:
If you can try my configuration and report what you observe, that would be great.
Closing due to inactivity.
Hello.
Describe the bug DriverContext of "driverFactory" contains "default" as "dataSource" when "sql" method is used. But works as expected with "load" method.
To Reproduce 1- Instantiate a CubeServerCore with "driverFactory" creation option.
2- Instantiate a cube api instance with "cube"
3- Call "load" method on cube
You will see that the actual source of the cube model(s) will be printed to console
4- Call "sql" method on cube
You will see that 'default' will be printed to console
Expected behavior I would expect both method calls to print actual dataSource name
Version: 0.35.67 [@cubejs-backend/server-core] 0.35.23 [@cubejs-client/core]
Additional context I am using the following create options when creating the core if it matters:
contextToAppId
schemaVersion
driverFactory
repositoryFactory
checkAuth