Skip to content

[Data - 2745] Fix update metadata#2866

Open
Zhimin-arya wants to merge 3 commits into
developfrom
Zhimin-arya/data-2745_fix_update_metadata
Open

[Data - 2745] Fix update metadata#2866
Zhimin-arya wants to merge 3 commits into
developfrom
Zhimin-arya/data-2745_fix_update_metadata

Conversation

@Zhimin-arya

@Zhimin-arya Zhimin-arya commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

The cause is when add new dataset:

  1. The cache_id hasn't been passed down to the create_cache_file plugin, so the cache is written into {database_code}.db
    Fix: derive cache_id after new dataset created and pass it when trigger create_cache_file plugin
  2. After new dataset created, the trex didn't create the cache_id.db accordingly.
    Fix: set createDbFileIfMissing: true
  3. When update the metadata, each dataset check against its own cache_id catalog

Before:

image

After:

image

Merge Checklist

Please cross check this list if additions / modifications needs to be done on top of your core changes and tick them off. Reviewer can as well glance through and help the developer if something is missed out.

  • Automated Tests (Jasmine integration tests, Unit tests, and/or Performance tests)
  • Updated Manual tests / Demo Config
  • Documentation (Application guide, Admin guide, Markdown, Readme and/or Wiki)
  • Verified that local development environment is working with latest changes (integrated with latest develop branch)
  • following best practices in code review doc

@Zhimin-arya Zhimin-arya marked this pull request as ready for review July 7, 2026 10:55
Copilot AI review requested due to automatic review settings July 7, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix dataset “update metadata” / cache-related behavior by ensuring cache DB files can be attached/created when missing and by propagating a cache_id through dataset creation and cache creation flows.

Changes:

  • Trex startup and DBM attach route now call ensureAttached(..., { createDbFileIfMissing: true }) when attaching cache DBs.
  • Dataset function now includes a derived cache_id in the create_datamodel flow options payload.
  • Cache DB file creation flow now uses cache_id (when provided) to choose the DuckDB target database name and DuckDB file path; OMOP CDM flow passes cacheId through to the cache creation flow.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/trex/core/server/routes/dbm.ts Enables creating/attaching cache DB files on-demand during the DBM attach request.
services/trex/core/server/index.ts Enables creating/attaching cache DB files during Trex startup attach phase.
plugins/functions/dataset/index.ts Adds cache_id derivation and sends it to the datamodel creation flow.
plugins/flows/base/omop_cdm_plugin/flow.py Passes cacheId into CreateCacheOptions so cache creation uses the intended cache identifier.
plugins/flows/base/create_cachedb_file_plugin/flow.py Uses cache_id (if set) to determine DuckDB file path and target database alias.

Comment on lines +42 to +48
private deriveCacheId(datasetId: string, databaseCode: string, dialect: DbDialect) {
if (dialect === DbDialect.Hana) {
return databaseCode;
}
const cleaned = datasetId.replace(/-/g, "_");
return /^[0-9]/.test(cleaned) ? `_${cleaned}` : cleaned;
}
@Zhimin-arya Zhimin-arya linked an issue Jul 7, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Update metadata schema not found

2 participants