cube-js/cube · error

CUBEJS_DB_NAME can`t be empty.

Error message

CUBEJS_DB_NAME can`t be empty.

What it means

DremioDriver.tablesSchema() requires a database name to introspect tables. Before querying Dremio for the table schema it checks this.config.database, which is populated from the CUBEJS_DB_NAME environment variable, and throws this error when it is empty or undefined. Introspection cannot proceed without knowing which Dremio database (source) to inspect.

Source

Thrown at packages/cubejs-dremio-driver/driver/DremioDriver.js:261

  }

  async refreshTablesSchema(path) {
    const { data } = await this.restDremioQuery('get', `/catalog/by-path/${path}`);
    if (!data || !data.children) {
      return true;
    }

    const queries = data.children.map(element => {
      const url = element.path.join('/');
      return this.refreshTablesSchema(url);
    });

    return Promise.all(queries);
  }

  async tablesSchema() {
    if (!this.config.database) {
      throw new Error('CUBEJS_DB_NAME can`t be empty.');
    }

    // By some reason query generated by super.tablesSchema will return only tables that we usd before
    // So, function refreshTablesSchema used for get all tables by rest api.
    // After this, query generated by super.tablesSchema will return all table`s.
    await this.refreshTablesSchema(this.config.database);
    return super.tablesSchema();
  }

  informationSchemaQuery() {
    const q = `${super.informationSchemaQuery()} AND columns.table_schema NOT IN ('INFORMATION_SCHEMA', 'sys.cache')`;
    console.log(q);
    return q;
  }
}

module.exports = DremioDriver;
module.exports.applyParams = applyParams;

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Set CUBEJS_DB_NAME in your environment to the Dremio database/source name to introspect.
  2. Alternatively pass `database: '<name>'` explicitly in the driver configuration object.
  3. Verify with a preflight check in your cube.js bootstrap that process.env.CUBEJS_DB_NAME is non-empty when dbType is dremio.

Example fix

// before (.env)
CUBEJS_DB_HOST=dremio.example.com
CUBEJS_DB_USER=admin
# CUBEJS_DB_NAME missing
// after
CUBEJS_DB_HOST=dremio.example.com
CUBEJS_DB_USER=admin
CUBEJS_DB_NAME=my_dremio_source
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.CUBEJS_DB_NAME) {
  throw new Error('Set CUBEJS_DB_NAME before starting the Dremio driver');
}

Type guard

function hasDatabase(cfg) {
  return typeof cfg?.database === 'string' && cfg.database.length > 0;
}

Try / catch

try {
  await driver.tablesSchema();
} catch (e) {
  if (e.message.includes('CUBEJS_DB_NAME')) {
    // fix config and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Calling driver.tablesSchema() (directly or via Cube Store schema introspection) when the driver config was created without a `database` field — typically because CUBEJS_DB_NAME was not set in the environment or the data source config.

Common situations: Deploying Cube for Dremio with an incomplete .env file; forgetting to configure CUBEJS_DB_NAME while only setting host/port/user credentials; renaming config keys and dropping `database` from the driver options.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/8cf34c1fbd32cb56. Report an issue: GitHub.