Skip to content

feat: clean up table reference type boundaries - #775

Merged
ilyabo merged 17 commits into
mainfrom
codex/table-reference-type-boundary-cleanup
Jul 1, 2026
Merged

ilyabo merged 17 commits into
mainfrom
codex/table-reference-type-boundary-cleanup

Conversation

@ilyabo

@ilyabo ilyabo commented Jun 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add explicit table reference boundary types and helpers in @sqlrooms/duckdb-core
  • migrate high-risk SQL, Mosaic/vgplot, state, lookup, AI, and display paths to explicit identity/reference helpers
  • add regression coverage for quoted/dotted identifiers, selected-table identity persistence, and SQL boundary type friction
  • align Kepler and AI package test configuration so the repo-wide pre-push suite exercises the new ESM/source boundaries correctly

Validation

  • pnpm build
  • pnpm --filter @sqlrooms/duckdb-core test -- --runTestsByPath packages/duckdb-core/__tests__/getUnqualifiedSqlIdentifier.test.ts
  • pnpm --filter @sqlrooms/deck build
  • pnpm --filter @sqlrooms/cells build
  • pnpm --filter @sqlrooms/pivot build
  • pnpm --filter @sqlrooms/mosaic build
  • pnpm --filter @sqlrooms/pivot test -- --runTestsByPath packages/pivot/__tests__/pivot-sql.test.ts
  • pnpm --filter @sqlrooms/deck test -- --runTestsByPath packages/deck/__tests__/dashboard-ai-map.test.ts
  • pnpm --filter @sqlrooms/cells test -- --runTestsByPath packages/cells/__tests__/resultRelationPolicy.test.ts
  • pnpm --filter @sqlrooms/kepler test -- --runTestsByPath packages/kepler/__tests__/keplerTableSelection.test.ts
  • pnpm --filter @sqlrooms/ai test
  • pre-push hook: knip, turbo typecheck, turbo test

Notes

  • Updated the Obsidian implementation plan stage checklists and notes as the work progressed.
  • A direct pnpm --filter sqlrooms-cli-app build attempt exposed existing unrelated app-wide declaration/type issues around missing package declarations and implicit anys; the final root pnpm build and full pre-push suite passed.

Summary by CodeRabbit

  • New Features

    • Table selections across dashboards, maps, pivot views, and data explorers now use a canonical table identity consistently.
    • Table SQL generation now relies on standardized, SQL-safe raw table references.
  • Bug Fixes

    • Fixed quoted/dotted table names being incorrectly rewritten or split in map/dashboard dataset query handling.
    • Improved error handling by rejecting unparseable/invalid table references earlier in SQL-boundary paths.
  • Documentation

    • Added developer documentation outlining table-reference ownership and boundary rules.
  • Tests

    • Expanded coverage to validate identity propagation and quoted identifier rewriting behavior.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds branded table-identity helpers in duckdb-core and updates downstream packages to use canonical identities, display names, and validated raw SQL references across UI selection, query construction, and boundary handling.

Changes

Branded Table Identity and Reference Migration

Layer / File(s) Summary
duckdb-core branded types and helpers
packages/duckdb-core/src/duckdb-utils.ts, packages/duckdb-core/src/index.ts, packages/duckdb/src/index.ts
Adds branded TableIdentity, FullTableIdentity, and RawSqlTableReference types plus helpers for deriving, parsing, rehydrating, and quoting table identities; re-exports them from the package entrypoints.
duckdb-core tests and docs
packages/duckdb-core/__tests__/getUnqualifiedSqlIdentifier.test.ts, packages/duckdb-core/README.md, dev-docs/table-reference-type-boundary-inventory.md
Adds boundary tests for the new helpers and updates the README and developer documentation to describe the helper-based table reference flow.
Downstream identity and label consumers
packages/mosaic/src/..., packages/kepler/src/..., packages/ai/src/..., packages/ai/jest.config.js, packages/mosaic/src/index.ts, packages/duckdb/src/index.ts
Switches Mosaic, Kepler, and AI code to use canonical table identities and display names, updates Mosaic reference types, and adjusts package re-exports and Jest resolution.
Deck, cells, pivot, and CLI SQL boundaries
packages/deck/src/..., packages/deck/__tests__/..., packages/cells/src/..., packages/cells/__tests__/..., packages/pivot/src/..., packages/pivot/__tests__/..., apps/sqlrooms-cli-ui/src/store.ts
Reworks deck map quoting/query building, cell result relation quoting, pivot source typing, and CLI Python bridge table reads to validate and quote SQL table references at the boundary.
CLI UI worksheet and sidebar flows
apps/sqlrooms-cli-ui/src/createWorksheetCommands.ts, apps/sqlrooms-cli-ui/src/workspace/sidebar/CliDataSidebarSection.tsx, apps/sqlrooms-cli-ui/src/components/useAssistantContextItems.ts, apps/sqlrooms-cli-ui/src/context/getRunContext.ts, apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts
Propagates canonical table identities through worksheet commands, sidebar selection, assistant context items, run context lookup, and related tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#671: Changes Kepler table-name handling for map dataset wiring, overlapping with the Kepler identity updates here.
  • sqlrooms/sqlrooms#732: Touches the same CLI UI context and selection flow files updated in this PR.
  • sqlrooms/sqlrooms#734: Also standardizes qualified DuckDB table-reference handling across shared helpers and downstream consumers.

Suggested reviewers

  • dmitriy-kostianetskiy
  • lixun910

🐇 I hopped through helpers, neat and round,
With quoted names and types well-grounded.
No bare table strings to see,
Just tidy IDs for you and me.
The rabbit cheers: “Hop, hop, hooray!” ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.54% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: introducing explicit table reference boundary helpers and types.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/table-reference-type-boundary-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ilyabo
ilyabo marked this pull request as ready for review June 30, 2026 10:04

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (5)
packages/deck/__tests__/dashboard-ai-map.test.ts (1)

195-223: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression for the new error paths.

These tests only lock in the happy path. quoteDeckMapSqlTableReference(...) and the non-sqlQuery createDeckMapBoundsQuery(...) path now throw on invalid table sources, so a small assertion for those failures would protect the behavioral change too.

Possible follow-up
+  it('throws for invalid bounds table sources', () => {
+    expect(() =>
+      createDeckMapBoundsQuery({
+        source: {},
+        fitToData: {
+          dataset: 'events',
+          longitudeColumn: 'lon',
+          latitudeColumn: 'lat',
+        },
+      }),
+    ).toThrow('Deck map fit-to-data requires a valid table source.');
+  });
+
+  it('throws for invalid raw table references', () => {
+    expect(() => quoteDeckMapSqlTableReference('')).toThrow(
+      'Invalid deck map table reference',
+    );
+  });

As per coding guidelines, **/*.{js,ts,jsx,tsx}: Add or update tests when changing behavior or public API, when practical.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/deck/__tests__/dashboard-ai-map.test.ts` around lines 195 - 223, The
current tests cover only the successful quoting behavior in
createDeckMapBoundsQuery and quoteDeckMapSqlTableReference, but they miss the
new invalid-table-source error paths. Add regression assertions in the existing
dashboard-ai-map test suite that verify quoteDeckMapSqlTableReference throws for
malformed table references and that the non-sqlQuery branch of
createDeckMapBoundsQuery rejects invalid source/table input, using those
function names to locate the cases.

Source: Coding guidelines

apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts (1)

129-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add assertions for the other identity-returning worksheet commands.

This now covers the dashboard path, but worksheet.add-data-table-block and worksheet.add-map-block in apps/sqlrooms-cli-ui/src/createWorksheetCommands.ts also switched their selectedTable payloads to canonical identities. Please add those two regression checks here as well so the updated response contract is exercised end-to-end.

As per coding guidelines, **/*.{js,ts,jsx,tsx}: Add or update tests when changing behavior or public API, when practical.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts` around
lines 129 - 143, Add regression assertions for the other identity-returning
worksheet commands in the createWorksheetCommands test suite. The current test
only verifies the dashboard path, but the behavior change in
createWorksheetCommands means worksheet.add-data-table-block and
worksheet.add-map-block should also be checked for canonical selectedTable
payloads. Update
apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts to assert the
invokeCommand calls for those two commands using the same identity-returning
values, alongside the existing dashboard.set-selected-table coverage.

Source: Coding guidelines

packages/mosaic/src/mosaicTableReference.ts (1)

51-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add TSDoc for the public helper functions.

These helpers are now part of the package-facing table-reference API, but the changed exports still are undocumented. Please add brief docs so callers can distinguish the AST, raw-SQL, and vgplot boundaries. As per coding guidelines, packages/**/*.{ts,tsx}: Add tsdoc to exported types and functions in @sqlrooms/* packages.

Also applies to: 76-94

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mosaic/src/mosaicTableReference.ts` around lines 51 - 55, The
exported table-reference helpers and types in this module are undocumented, so
add brief TSDoc to the public API symbols such as getMosaicSqlTableReference,
getMosaicTableReferenceParts, and the related exported types so callers can tell
how the AST, raw-SQL, and vgplot representations differ. Keep the docs concise
but explicit about each helper’s boundary and input/output shape, and make sure
all package-facing exports in this area follow the same TSDoc style.

Source: Coding guidelines

packages/mosaic/src/data-table-explorer/types.ts (1)

91-91: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add TSDoc for this exported alias.

This narrows a public package type, so it should carry its own short contract doc. As per coding guidelines, packages/**/*.{ts,tsx}: Add tsdoc to exported types and functions in @sqlrooms/* packages.

Proposed doc block
+/** Canonical Mosaic SQL table reference used by data-table explorer queries. */
 export type DataTableExplorerSqlTableReference = MosaicSqlTableReference;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mosaic/src/data-table-explorer/types.ts` at line 91, Add a short
TSDoc block for the exported type alias DataTableExplorerSqlTableReference in
types.ts so the public contract is documented like other `@sqlrooms/`* exports.
Keep the doc concise, describing that it is the DataTableExplorer-specific alias
for MosaicSqlTableReference, and place it directly above the export so the
symbol is documented even if the alias definition changes.

Source: Coding guidelines

packages/pivot/src/sql.ts (1)

26-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add TSDoc to the exported raw-reference helpers.

These exports now define the pivot package's public RawSqlTableReference boundary, but callers still have no inline contract explaining which helper should produce that type.

Suggested doc shape
+/**
+ * Creates a pivot query source from a validated raw SQL table reference.
+ * Pass `getRawSqlTableReference(...)` or `quoteParsedRawSqlTableReference(...)`,
+ * not a persisted table identity.
+ */
 export function createPivotQuerySource(
   tableRef: RawSqlTableReference,
   columns: PivotField[],
 ): PivotQuerySource {
   return {tableRef, columns};
 }
 
+/**
+ * Creates a pivot query source from a `DataTable` by deriving its raw SQL
+ * table reference.
+ */
 export function createPivotQuerySourceFromTable(
   table: DataTable,
 ): PivotQuerySource {

As per coding guidelines, packages/**/*.{ts,tsx} should add tsdoc to exported types and functions in @sqlrooms/* packages, and packages/** public exports should stay documented library APIs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/pivot/src/sql.ts` around lines 26 - 37, Add TSDoc comments to the
exported helpers in createPivotQuerySource and createPivotQuerySourceFromTable
so the public RawSqlTableReference contract is documented inline. Explain that
createPivotQuerySource accepts an existing RawSqlTableReference plus columns,
while createPivotQuerySourceFromTable builds the reference from table.table via
getRawSqlTableReference; keep the docs on these exported symbols so callers know
which helper to use.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cells/src/resultRelationPolicy.ts`:
- Around line 34-41: The relation-name handling in resultRelationPolicy should
normalize all inputs through quoteParsedRawSqlTableReference instead of
returning QualifiedTableName via toString() early. Update the logic around the
relationName branch so both string and non-string inputs use the same
quoting/validation path, and only fall back to an error when the helper rejects
the value. Keep the fix localized to the result relation policy flow so CREATE,
DROP, and RENAME all get consistent SQL-boundary behavior regardless of caller
type.

In `@packages/duckdb-core/src/duckdb-utils.ts`:
- Around line 177-180: `getFullTableIdentity` is branding unresolved
`QualifiedTableName` values as `FullTableIdentity`, which lets partial `{table}`
or `{schema, table}` inputs slip through. Update `getFullTableIdentity` in
`duckdb-utils.ts` to only accept or construct truly complete identities, and
reject incomplete shapes before calling `toFullString()` so the returned value
is always something `parseFullTableIdentity()` can successfully round-trip. Use
the `QualifiedTableName`, `FullTableIdentity`, and `parseFullTableIdentity`
symbols to align the validation with the new boundary type.

---

Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts`:
- Around line 129-143: Add regression assertions for the other
identity-returning worksheet commands in the createWorksheetCommands test suite.
The current test only verifies the dashboard path, but the behavior change in
createWorksheetCommands means worksheet.add-data-table-block and
worksheet.add-map-block should also be checked for canonical selectedTable
payloads. Update
apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts to assert the
invokeCommand calls for those two commands using the same identity-returning
values, alongside the existing dashboard.set-selected-table coverage.

In `@packages/deck/__tests__/dashboard-ai-map.test.ts`:
- Around line 195-223: The current tests cover only the successful quoting
behavior in createDeckMapBoundsQuery and quoteDeckMapSqlTableReference, but they
miss the new invalid-table-source error paths. Add regression assertions in the
existing dashboard-ai-map test suite that verify quoteDeckMapSqlTableReference
throws for malformed table references and that the non-sqlQuery branch of
createDeckMapBoundsQuery rejects invalid source/table input, using those
function names to locate the cases.

In `@packages/mosaic/src/data-table-explorer/types.ts`:
- Line 91: Add a short TSDoc block for the exported type alias
DataTableExplorerSqlTableReference in types.ts so the public contract is
documented like other `@sqlrooms/`* exports. Keep the doc concise, describing that
it is the DataTableExplorer-specific alias for MosaicSqlTableReference, and
place it directly above the export so the symbol is documented even if the alias
definition changes.

In `@packages/mosaic/src/mosaicTableReference.ts`:
- Around line 51-55: The exported table-reference helpers and types in this
module are undocumented, so add brief TSDoc to the public API symbols such as
getMosaicSqlTableReference, getMosaicTableReferenceParts, and the related
exported types so callers can tell how the AST, raw-SQL, and vgplot
representations differ. Keep the docs concise but explicit about each helper’s
boundary and input/output shape, and make sure all package-facing exports in
this area follow the same TSDoc style.

In `@packages/pivot/src/sql.ts`:
- Around line 26-37: Add TSDoc comments to the exported helpers in
createPivotQuerySource and createPivotQuerySourceFromTable so the public
RawSqlTableReference contract is documented inline. Explain that
createPivotQuerySource accepts an existing RawSqlTableReference plus columns,
while createPivotQuerySourceFromTable builds the reference from table.table via
getRawSqlTableReference; keep the docs on these exported symbols so callers know
which helper to use.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2114ba69-d716-4251-8ad6-62ee8a1e952f

📥 Commits

Reviewing files that changed from the base of the PR and between 862da01 and 8e165cf.

📒 Files selected for processing (41)
  • apps/sqlrooms-cli-ui/src/__tests__/createWorksheetCommands.test.ts
  • apps/sqlrooms-cli-ui/src/components/useAssistantContextItems.ts
  • apps/sqlrooms-cli-ui/src/context/getRunContext.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetCommands.ts
  • apps/sqlrooms-cli-ui/src/store.ts
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliDataSidebarSection.tsx
  • dev-docs/table-reference-type-boundary-inventory.md
  • packages/ai/jest.config.js
  • packages/ai/src/tools/tableSchemaContext.ts
  • packages/ai/src/tools/tables/tableIdentity.ts
  • packages/cells/__tests__/resultRelationPolicy.test.ts
  • packages/cells/src/resultRelationPolicy.ts
  • packages/deck/__tests__/dashboard-ai-map.test.ts
  • packages/deck/__tests__/dashboard.test.ts
  • packages/deck/src/block.tsx
  • packages/deck/src/dashboardConfig.ts
  • packages/deck/src/mapConfigUtils.ts
  • packages/deck/src/useDeckMapFitToBounds.ts
  • packages/duckdb-core/README.md
  • packages/duckdb-core/__tests__/getUnqualifiedSqlIdentifier.test.ts
  • packages/duckdb-core/src/duckdb-utils.ts
  • packages/duckdb-core/src/index.ts
  • packages/duckdb/src/index.ts
  • packages/kepler/package.json
  • packages/kepler/src/KeplerSlice.ts
  • packages/kepler/src/keplerTableSelection.ts
  • packages/mosaic/src/charts/worksheet/ChartBlockRenderer.tsx
  • packages/mosaic/src/components/DataTableSelector.tsx
  • packages/mosaic/src/data-table-explorer/DataTableExplorerCategoryClient.ts
  • packages/mosaic/src/data-table-explorer/DataTableExplorerCountClient.ts
  • packages/mosaic/src/data-table-explorer/DataTableExplorerHistogramClient.ts
  • packages/mosaic/src/data-table-explorer/DataTableExplorerPageClient.ts
  • packages/mosaic/src/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.ts
  • packages/mosaic/src/data-table-explorer/types.ts
  • packages/mosaic/src/data-table-explorer/worksheet/DataTableBlockRenderer.tsx
  • packages/mosaic/src/index.ts
  • packages/mosaic/src/mosaicTableReference.ts
  • packages/pivot/__tests__/pivot-sql.test.ts
  • packages/pivot/src/pivotCellRegistryEntry.tsx
  • packages/pivot/src/sql.ts
  • packages/pivot/src/types.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6751661f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/deck/src/dashboardConfig.ts Outdated
}): {tableName?: string; sqlQuery?: string} | undefined {
const datasetSource = options.dataset?.source;
const dashboardTable = stripCatalogPrefix(options.dashboard.selectedTable);
const dashboardTable = options.dashboard.selectedTable;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize catalog-qualified map table identities

When dashboard.selectedTable is a full persisted identity such as "memory"."main"."events" or an attached-catalog table, this now passes the catalog through as the map data source. The map query builders below call quoteParsedRawSqlTableReference, which preserves all three parts, so dataset and fit-to-data SQL will use FROM "memory"."main"."events"; the surrounding Mosaic table-reference code intentionally drops the catalog for the active connector. This regresses dashboards/maps restored with full table identities or selected from non-default catalogs; the previous normalization avoided sending the catalog into Deck map runtime SQL.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/deck/src/dashboardConfig.ts (1)

112-131: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Normalize originalTable before comparing and building rewrite patterns.

Line 112 strips the catalog from dashboard.selectedTable, but Line 124 still compares against the unnormalized datasetSource.tableName. If the stored source is catalog-qualified while the SQL uses the runtime schema/table form, the dashboard table switch can skip the intended FROM rewrite.

Suggested direction
-    const originalTable = datasetSource.tableName;
+    const originalTable = stripCatalogPrefix(datasetSource.tableName);

Also build the quoted-original pattern from the same normalized reference helper so quoted dotted identifiers stay consistent with the new boundary helpers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/deck/src/dashboardConfig.ts` around lines 112 - 131, Normalize the
source table before comparing and rewriting in dashboardConfig so the SQL
rewrite logic uses the same table form as stripCatalogPrefix does for the
selected dashboard table. In dashboardConfig’s SQL branch, update the
originalTable comparison and the quoted-original pattern generation to use a
shared normalized reference instead of datasetSource.tableName directly, so
catalog-qualified tables still trigger the intended FROM-clause rewrite and
quoted dotted identifiers stay consistent with the existing boundary helpers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/deck/src/dashboardConfig.ts`:
- Around line 112-131: Normalize the source table before comparing and rewriting
in dashboardConfig so the SQL rewrite logic uses the same table form as
stripCatalogPrefix does for the selected dashboard table. In dashboardConfig’s
SQL branch, update the originalTable comparison and the quoted-original pattern
generation to use a shared normalized reference instead of
datasetSource.tableName directly, so catalog-qualified tables still trigger the
intended FROM-clause rewrite and quoted dotted identifiers stay consistent with
the existing boundary helpers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0c7a727b-3059-4255-887d-5e190968fa0a

📥 Commits

Reviewing files that changed from the base of the PR and between a675166 and 96187b8.

📒 Files selected for processing (2)
  • packages/deck/__tests__/dashboard.test.ts
  • packages/deck/src/dashboardConfig.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/deck/tests/dashboard.test.ts

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
packages/deck/src/MapSettings.tsx (1)

170-170: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: dedupe useDataTable(dashboardSelectedTable).

selectedDataTable (Line 170) and primaryTable (Line 204) issue the same useDataTable(dashboardSelectedTable) call. Reusing a single value would avoid the redundant store read.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/deck/src/MapSettings.tsx` at line 170, `selectedDataTable` and
`primaryTable` both call `useDataTable(dashboardSelectedTable)`, so the same
store read is being duplicated. Update `MapSettings` to compute this value once
and reuse it for both `selectedDataTable` and `primaryTable`, keeping the
existing `useDataTable` result as the single source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/deck/src/MapSettings.tsx`:
- Line 170: `selectedDataTable` and `primaryTable` both call
`useDataTable(dashboardSelectedTable)`, so the same store read is being
duplicated. Update `MapSettings` to compute this value once and reuse it for
both `selectedDataTable` and `primaryTable`, keeping the existing `useDataTable`
result as the single source of truth.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc109df3-2403-4ab6-9e21-44828a890201

📥 Commits

Reviewing files that changed from the base of the PR and between 96187b8 and a07cf8d.

📒 Files selected for processing (13)
  • apps/sqlrooms-cli-ui/src/store.ts
  • packages/deck/src/BlockMapSettings.tsx
  • packages/deck/src/DashboardMapSettings.tsx
  • packages/deck/src/MapSettings.tsx
  • packages/deck/src/block.tsx
  • packages/mosaic/src/charts/block-document/ChartBlockRenderer.tsx
  • packages/mosaic/src/charts/block-document/ChartBlockSettings.tsx
  • packages/mosaic/src/charts/dashboard/MosaicDashboardChartSettings.tsx
  • packages/mosaic/src/dashboard/MosaicDashboardSettings.tsx
  • packages/mosaic/src/data-table-explorer/block-document/DataTableBlockRenderer.tsx
  • packages/mosaic/src/data-table-explorer/block-document/DataTableBlockSettings.tsx
  • packages/mosaic/src/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerSettings.tsx
  • packages/mosaic/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/mosaic/src/index.ts
  • apps/sqlrooms-cli-ui/src/store.ts
  • packages/deck/src/block.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac6be2b63a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/deck/src/dashboardConfig.ts Outdated
'gi',
),
`FROM ${quotedDashboard}`,
const originalTable = stripCatalogPrefix(datasetSource.tableName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve catalog-qualified source when rewriting map SQL

When a saved map has both dataset.source.tableName and its sqlQuery using the same catalog-qualified reference, such as FROM "memory"."main"."old_events", and the dashboard selected table changes, this strips the source to "main"."old_events" before building the match candidates. The replacement loop then never matches the 3-part FROM in the SQL but still returns the unchanged query, so the dashboard's selected table no longer takes precedence and the map can keep querying a stale or unavailable catalog-qualified source. Include the original unstripped source reference among the rewrite candidates before normalizing it for runtime SQL.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8210ed190

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/deck/src/dashboardConfig.ts Outdated

if (originalTable) {
const quotedOriginal = quoteRuntimeTableReference(originalTable);
if (quotedOriginal && quotedOriginal !== quotedDashboard) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize matching catalog-qualified map SQL

When a saved map's dataset.source.tableName and sqlQuery already match the dashboard table but are catalog-qualified, e.g. selected/source table are "memory"."main"."events" and the SQL is SELECT * FROM "memory"."main"."events", originalTable and dashboardTable both normalize to "main"."events". This guard then skips the replacement loop entirely, so the runtime dataset and fit-to-data queries still use the catalog-qualified FROM, even though this path is supposed to strip catalogs before handing SQL to Mosaic. Even after adding the unstripped source candidate, the fresh failure is the equality check hiding the catalog difference.

Useful? React with 👍 / 👎.

@ilyabo
ilyabo merged commit 3864f8f into main Jul 1, 2026
4 checks passed
@ilyabo
ilyabo deleted the codex/table-reference-type-boundary-cleanup branch July 1, 2026 08:02
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.

1 participant