{"record":{"id":"e418336ca478d715","repo":"mem0ai/mem0","slug":"the-databricks-sql-package-is-required-to-use-t","errorCode":null,"errorMessage":"The '@databricks/sql' package is required to use the Databricks vector store. Install it with: npm install @databricks/sql (original error: ${detail})","messagePattern":"The '@databricks/sql' package is required to use the Databricks vector store\\. Install it with: npm install @databricks/sql \\(original error: (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/databricks.ts","lineNumber":1059,"sourceCode":"   * on the first SQL call instead, the way milvus.ts and baidu.ts load theirs.\n   *\n   * This MUST be a dynamic `import()`, never `require()`: tsup/esbuild rewrite `require()` in\n   * the published ESM bundle (`dist/oss/index.mjs`) into a `__require` shim that throws\n   * `Dynamic require of \"...\" is not supported`, so every ESM consumer would hit a dead\n   * provider even with the driver installed.\n   */\n  private async getSqlModule(): Promise<{\n    DBSQLClient: new () => DatabricksSqlClientLike;\n  }> {\n    if (!this.sqlModulePromise) {\n      this.sqlModulePromise = import(\"@databricks/sql\").then(\n        (mod) =>\n          mod as unknown as { DBSQLClient: new () => DatabricksSqlClientLike },\n        (err) => {\n          // Let a later call retry rather than caching the rejection forever.\n          this.sqlModulePromise = undefined;\n          const detail = err instanceof Error ? err.message : String(err);\n          throw new Error(\n            \"The '@databricks/sql' package is required to use the Databricks vector store. \" +\n              `Install it with: npm install @databricks/sql (original error: ${detail})`,\n          );\n        },\n      );\n    }\n    return this.sqlModulePromise;\n  }\n\n  private async getSqlClient(): Promise<DatabricksSqlClientLike> {\n    if (!this.sqlClient) {\n      const { DBSQLClient } = await this.getSqlModule();\n      this.sqlClient = new DBSQLClient();\n    }\n    return this.sqlClient;\n  }\n\n  private async openSession(): Promise<DatabricksSqlSessionLike> {","sourceCodeStart":1041,"sourceCodeEnd":1077,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/databricks.ts#L1041-L1077","documentation":"The store lazily imports @databricks/sql for SQL warehouse connections. If the package is not installed (it is an optional peer dependency), the dynamic import rejects; the store wraps that with install instructions and the original error, and clears the cached promise so a later call can retry after installing.","triggerScenarios":"Using the Databricks vector store without @databricks/sql in package.json — the first operation needing a SQL session (createTable, insert, list, etc.) triggers getSqlModule() and throws.","commonSituations":"Fresh clone after the dependency was moved to optional peerDeps; using a package manager that skipped optional peers; bundlers that tree-shake or fail to resolve the dynamic import.","solutions":["Install it: npm install @databricks/sql (or pnpm add @databricks/sql)","After installing, the retry works without code changes — the failed import is not cached","In Docker/CI builds, ensure the install step includes optional peer dependencies"],"exampleFix":"# before\nnpm install mem0ai\n\n# after\nnpm install mem0ai @databricks/sql","handlingStrategy":"try-catch","validationCode":"async function hasDatabricksSql(): Promise<boolean> {\n  try { await import('@databricks/sql'); return true; } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { await store.list(); } catch (e) { if (e instanceof Error && e.message.includes(\"'@databricks/sql'\")) { await exec('npm install @databricks/sql'); /* retry once */ } throw e; }","preventionTips":["Add @databricks/sql to package.json alongside mem0ai when using the Databricks store","Run a smoke test (list() once) at deployment start to surface missing optional deps early"],"tags":["databricks","dependencies","installation","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}