panoti / cubejs-arangodb-driver

ArangoDB driver for Cube JS
MIT License
5 stars 1 forks source link

Unsupported db type: arangodb with cube:latest (0.30.39) #1

Closed tokarenko closed 1 year ago

tokarenko commented 1 year ago

ghcr.io/panoti/cube:main seems to be inoperable with the latest (0.30.39) Cube version.

Error while loading DB schema
Error: Unsupported db type: arangodb
at Object.driverDependencies (/cube/node_modules/@cubejs-backend/server-core/src/core/DriverResolvers.ts:24:9)
at Object.lookupDriverClass (/cube/node_modules/@cubejs-backend/server-core/src/core/DriverResolvers.ts:36:5)
at Function.createDriver (/cube/node_modules/@cubejs-backend/server-core/src/core/DriverResolvers.ts:50:23)
at CubejsServerCore.resolveDriver (/cube/node_modules/@cubejs-backend/server-core/src/core/server.ts:750:28)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at CubejsServerCore.getDriver (/cube/node_modules/@cubejs-backend/server-core/src/core/server.ts:723:22)
at /cube/node_modules/@cubejs-backend/server-core/src/core/DevServer.ts:108:22
at /cube/node_modules/@cubejs-backend/server-core/src/core/DevServer.ts:78:9

I would be grateful if you could help to resolve the issue.

panoti commented 1 year ago

Could you provide to me your column type @tokarenko ? because I cannot support all data types 😅

tokarenko commented 1 year ago

@panoti, thank you for the feedback and the driver!

In the meantime I resolved the issue. The root cause is that the driver doesn't pass isDriver() check/. I suggest to change the driver class definition to inherit from the BaseDriver as in PostgresDriver

The driver works with the following initialization code in cube.js:

const arango_db_driver = require("arangodb-cubejs-driver/dist/arangodb-driver.js").ArangoDbDriver;
const base_driver = require("@cubejs-backend/query-orchestrator").BaseDriver;

module.exports = {
  dbType: () => {
    return process.env.CUBEJS_DB_TYPE;
  },

  driverFactory: () => {

    // Workaround for the absence of inheritance from BaseDriver
    Object.setPrototypeOf(arango_db_driver.prototype,base_driver.prototype)

    return new arango_db_driver({
      url: process.env.CUBEJS_DB_URL,
      databaseName: process.env.CUBEJS_DB_NAME,
      auth: {
        username: process.env.CUBEJS_DB_USER,
        password: process.env.CUBEJS_DB_PASS,
      },
    });
  },
};
panoti commented 1 year ago

Ah, I believe my driver is really outdated. I will update it soon.

tokarenko commented 1 year ago

Please wait for a PR from me today with further modifications to make the driver work with any filters from the Cube GUI and allow for dynamic parameters in when calling the driver.

tokarenko commented 1 year ago

@panoti , please add me as a contributor because I am unable to create feature branch.

panoti commented 1 year ago

@tokarenko you can fork this repo, then create a PR. I think it will be easier than creating feature branch.

panoti commented 1 year ago

Thanks @tokarenko so much, I've upgrade this driver by using @cubejs-backend/base-driver and your wonderful contributing. Let check v0.1.0 for the new features.