Skip to content

feat(driver-sql): honor external.columnMap on federated objects (ADR-0015)#2149

Merged
xuyushun441-sys merged 1 commit into
mainfrom
feat/adr0015-external-columnmap
Jun 22, 2026
Merged

feat(driver-sql): honor external.columnMap on federated objects (ADR-0015)#2149
xuyushun441-sys merged 1 commit into
mainfrom
feat/adr0015-external-columnmap

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Why

Follow-up to ADR-0015 federation (#2138/#2139). When a federated (external) object's remote table has column names that differ from the local field names, you express the mapping with external.columnMap ({ remoteColumn → localField }). The spec accepted it, but the SQL driver's query pipeline ignored it — WHERE/ORDER BY/SELECT used the local field names as physical columns, so a columnMap'd object couldn't be queried correctly.

What

Scoped, additive, gated on external.columnMap being present — managed objects and external objects without a columnMap are byte-for-byte unchanged.

  • registerExternalObject inverts columnMap to localField → remoteColumn (and keeps the inverse for read remap).
  • A remoteColumn(object, field, fallback) helper resolves the physical column, falling back to each call-site's existing resolution when there's no columnMap.
  • WHERE (object / array / mongo-operator forms) and ORDER BY translate the local field to its remote column; value coercion stays keyed by the local field.
  • formatOutput renames remote-column keys back to local field names on read (no-op without a columnMap), so coercion and callers see local names.
  • Write payloads are key-remapped after formatInput.

Tests

sql-driver-external-columnmap.test.ts: reads return local field names from differently-named remote columns; WHERE (object/array/$gte), ORDER BY, and date-coercion all translate through the columnMap; a managed control object is unaffected. Full driver-sql suite green (189/189); sql-driver.ts reports 0 type errors. ADR-0015 §18 updated.

🤖 Generated with Claude Code

…0015)

When a federated (external) object declares external.columnMap
({ remoteColumn -> localField }), the SQL driver now translates the query
pipeline to the physical remote columns:
- registerExternalObject inverts columnMap to localField -> remoteColumn (+ keeps
  the inverse for read remap).
- WHERE (object/array/mongo forms) and ORDER BY resolve the local field to its
  remote column via remoteColumn(); value coercion stays keyed by the local field.
- formatOutput renames remote-column keys back to local field names on read
  (no-op when no columnMap), so coercion + callers see local names.
- write payloads are key-remapped after formatInput.

Managed objects and external objects without a columnMap are byte-for-byte
unchanged (the resolver falls back to each site's existing behavior). Adds
sql-driver-external-columnmap.test.ts (read/where/orderBy/date-coercion + managed
control). ADR-0015 §18 updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 22, 2026 2:01am

Request Review

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling labels Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/driver-sql.

8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/core/plugins.mdx (via @objectstack/driver-sql)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/driver-sql)
  • content/docs/concepts/terminology.mdx (via @objectstack/driver-sql)
  • content/docs/getting-started/glossary.mdx (via @objectstack/driver-sql)
  • content/docs/guides/driver-configuration.mdx (via @objectstack/driver-sql)
  • content/docs/guides/packages.mdx (via @objectstack/driver-sql)
  • content/docs/protocol/objectos/index.mdx (via @objectstack/driver-sql)
  • content/docs/protocol/objectos/lifecycle.mdx (via @objectstack/driver-sql)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@xuyushun441-sys
xuyushun441-sys merged commit 92db3e5 into main Jun 22, 2026
16 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the feat/adr0015-external-columnmap branch June 22, 2026 02:07
xuyushun441-sys added a commit that referenced this pull request Jun 22, 2026
…le, credentials, visibility, query completeness) (#2162)

Consolidates the runtime gaps surfaced while implementing ADR-0015 federation
(#2138 read path, #2149 columnMap, #2139 example+verify, #2157 visibility) into a
single forward decision: one DatasourceConnectionService that auto-connects
declared datasources as queryable engine drivers (no onEnable bridge), backward-
compatible opt-in gating (existing managed apps unchanged), credential resolution
at connect, native-analytics remote-table awareness, and columnMap/field.columnName
reconciliation. Status: Proposed; decisions D1-D8 with a phased rollout.

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants