Skip to content

fix(deck): resolve generated map selector columns - #783

Merged
ilyabo merged 6 commits into
mainfrom
codex/generated-column-map-selector
Jul 3, 2026
Merged

ilyabo merged 6 commits into
mainfrom
codex/generated-column-map-selector

Conversation

@ilyabo

@ilyabo ilyabo commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • split Deck map settings column sources into source-table columns and compiled dataset output columns
  • inspect transformed/pinned dataset output schemas with a schema-only LIMIT 0 query
  • route geometry, H3, arc, trips, color, and elevation selectors to the appropriate output/source columns
  • add generated-column runtime issue copy and schema helper coverage

Validation

  • pnpm --filter @sqlrooms/deck test --runInBand
  • pnpm --filter @sqlrooms/deck typecheck
  • pnpm --filter @sqlrooms/deck lint (passes with pre-existing warnings)
  • pnpm build
  • pre-push checks: knip, turbo typecheck, circular dependency check, turbo test

Summary by CodeRabbit

  • New Features

    • Added schema-aware deck map configuration, including a Trips timestamp-column selector and schema-driven options for color, geometry/H3, arc, and extrusion.
    • Added dataset-schema “Inspecting…”/error status while schema is loading.
  • Bug Fixes

    • Improved missing-column detection by recognizing DuckDB-style errors and validating additional geometry/timestamp/hexagon bindings.
    • Enhanced runtime messaging when required generated map output columns are not produced; preserved relevant source columns that resemble generated names.
  • Tests

    • Expanded coverage for dataset-schema inspection/resolution, SQL inspection wrapper behavior, and Arrow-to-DuckDB type normalization.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ilyabo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 524aa96e-3cc2-4805-971b-7217773f8a75

📥 Commits

Reviewing files that changed from the base of the PR and between 0d0e11b and 09337a9.

📒 Files selected for processing (2)
  • packages/deck/src/MapSettings.tsx
  • packages/deck/src/dashboard.tsx
📝 Walkthrough

Walkthrough

Adds dataset schema inspection helpers and hook, wires schema-derived columns into map settings, adds a layer timestamp-column setter, and updates dashboard missing-column handling.

Changes

Deck Map Dataset Schema

Layer / File(s) Summary
Dataset schema hook, helpers, and tests
packages/deck/src/useDeckMapDatasetSchema.ts, packages/deck/__tests__/useDeckMapDatasetSchema.test.ts
Adds schema inspection SQL generation, generated-column classification, Arrow-to-DuckDB type mapping, the dataset schema hook, and tests for SQL wrapping, column classification, and type conversion.
Layer timestamp column setter
packages/deck/src/mapLayerConfigUtils.ts
Adds setDeckMapLayerTimestampColumn to update a layer’s _sqlroomsBinding.timestampColumn.
MapSettings panel wiring to schema-derived columns
packages/deck/src/MapSettings.tsx
Resolves the active layer dataset schema and switches color, geometry, H3, arc, extrusion, timestamp, and latitude/longitude selectors to schema-derived columns.
Missing-column detection and runtime issue UI
packages/deck/src/dashboard.tsx
Extends missing-column parsing and schema checks, and shows a separate runtime issue message when missing columns are generated outputs.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#778: This PR uses createDeckMapDatasetOutputSchemaSql with the same deck table SQL wrapping path built around createDeckTableDatasetSql and the __sqlrooms_source CTE.
  • sqlrooms/sqlrooms#746: Both PRs touch packages/deck/src/MapSettings.tsx’s geometry/column selection logic.
  • sqlrooms/sqlrooms#777: Both PRs modify packages/deck/src/dashboard.tsx’s missing-column UI behavior.

Suggested reviewers: igorDykhta

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main Deck change around generated map selector columns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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/generated-column-map-selector

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.

@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: 8b792db1ae

ℹ️ 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 on lines +64 to +66
const dataOutputColumns = options.outputColumns.filter(
(column) => !isDeckMapGeneratedColumn(column.name),
);

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 real columns with generated-looking names

When the map uses a direct table source, useDeckMapDatasetSchema passes the table's sourceColumns through as outputColumns, so this name-only filter removes legitimate user columns named timestamps, source_geom, or target_geom from dataOutputColumns. Since MapSettings uses dataOutputColumns for the color and elevation selectors, a valid table with a real timestamps metric plus other columns can no longer select that field. The generated-column split should be gated to inspected transformed outputs or compare against sourceColumns so actual source fields remain selectable.

Useful? React with 👍 / 👎.

@ilyabo
ilyabo requested a review from igorDykhta July 1, 2026 21:04
@ilyabo
ilyabo force-pushed the codex/generated-column-map-selector branch from 8b792db to c781229 Compare July 1, 2026 21:06

@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: c781229227

ℹ️ 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 on lines +64 to +66
const isGeneratedOutputColumn = (column: TableColumn) =>
isDeckMapGeneratedColumn(column.name) &&
!sourceColumnNames.has(column.name);

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 opaque SQL aliases named like generated columns

For literal SQL dataset sources, MapSettings now inspects the query output but passes either no source columns or the dashboard-selected table's unrelated columns, so this name-based filter treats legitimate SQL aliases such as timestamps, source_geom, or target_geom as generated whenever the selected/source table does not contain the same name. In that case dataOutputColumns drops the alias, and the color/elevation selectors cannot choose it even though it is a real output of the pinned SQL query. The generated-column split should be disabled for opaque SQL sources or based on actual transform context rather than an empty/unrelated sourceColumns set.

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.

Actionable comments posted: 1

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

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

Duplicate JSX between generated-column and generic missing-column branches.

The blocks at Lines 184-203 and 206-222 are nearly identical, differing only in the lead sentence and the column list used. Consider extracting a shared render helper to avoid drift between the two messages.

♻️ Proposed refactor
+function MissingColumnsMessage({
+  intro,
+  columns,
+}: {
+  intro: string;
+  columns: string[];
+}) {
+  return (
+    <div className="flex h-full min-h-[200px] flex-col items-center justify-center p-4">
+      <div className="mb-2 text-center font-semibold">
+        The visualization can&apos;t be displayed
+      </div>
+      <div className="text-center text-sm">
+        <span>{intro} </span>
+        {columns.map((col, idx) => (
+          <span key={idx}>
+            <span className="inline-flex items-center rounded-md border border-gray-600 bg-gray-800 px-1 py-0.5 text-xs font-medium text-gray-300">
+              {col}
+            </span>{' '}
+          </span>
+        ))}
+      </div>
+    </div>
+  );
+}

Then in DeckMapRuntimeIssuePanel:

       if (generatedMissingColumns.length > 0) {
-        return (
-          <div className="flex h-full min-h-[200px] flex-col items-center justify-center p-4">
-            ...
-          </div>
-        );
+        return (
+          <MissingColumnsMessage
+            intro="The dataset transform did not produce required map output columns:"
+            columns={generatedMissingColumns}
+          />
+        );
       }
-      return (
-        <div className="flex h-full min-h-[200px] flex-col items-center justify-center p-4">
-          ...
-        </div>
-      );
+      return (
+        <MissingColumnsMessage
+          intro="Selected columns are missing in the dataset:"
+          columns={missingColumns}
+        />
+      );
🤖 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/dashboard.tsx` around lines 180 - 222, The missing-column
UI in DeckMapRuntimeIssuePanel duplicates nearly the same JSX in the
generated-column and generic branches. Extract a shared render helper or small
presentational component inside dashboard.tsx and have the existing
missingColumns/generatedMissingColumns branches pass only the message text and
column list so the layout stays consistent and avoids future drift.
packages/deck/src/mapLayerConfigUtils.ts (1)

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

Logic is correct; missing tsdoc.

setDeckMapLayerTimestampColumn correctly mirrors the setDeckMapLayerArcColumns pattern (merge into existing _sqlroomsBinding). It's missing a tsdoc comment though.

As per path instructions, "Add tsdoc to exported types and functions in @sqlrooms/* packages" for packages/**/*.{ts,tsx}.

🤖 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/mapLayerConfigUtils.ts` around lines 326 - 338, Add a tsdoc
comment for the exported function setDeckMapLayerTimestampColumn in
mapLayerConfigUtils so it matches the documentation style used by
setDeckMapLayerArcColumns and other exported APIs in `@sqlrooms` packages. Keep
the comment brief and describe that it updates the selected deck map layer’s
_sqlroomsBinding by setting timestampColumn while preserving any existing
binding fields.

Source: Path instructions

packages/deck/src/useDeckMapDatasetSchema.ts (2)

12-17: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Hardcoded generated-column names are a fragile heuristic.

GENERATED_COLUMN_NAMES hardcodes 4 names that must exactly match whatever the actual geometry/H3/arc/trips compiler emits. This is only saved from misclassifying real user data by the !sourceColumnNames.has(column.name) guard in resolveDeckMapDatasetSchema, but a custom pinned SQL query (or transform) that legitimately produces a column literally named timestamps, source_geom, or target_geom (not present in the raw source table) will still be silently treated as "generated" and excluded from data selectors, with no way for the user to override it.

Consider sourcing this list from wherever the compiler actually assigns these aliases (single source of truth) instead of duplicating the literal strings here, to avoid drift and false positives.

Also applies to: 61-72

🤖 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/useDeckMapDatasetSchema.ts` around lines 12 - 17, The
generated-column detection in useDeckMapDatasetSchema is relying on a hardcoded
GENERATED_COLUMN_NAMES set, which can misclassify legitimate columns like
timestamps, source_geom, and target_geom. Update resolveDeckMapDatasetSchema to
use a single source of truth for compiler-assigned aliases instead of
duplicating literals here, and wire the alias list from the same place that
defines the geometry/H3/arc/trips compiler output so the selector filtering
stays in sync and avoids false positives.

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

Missing tsdoc on new public exports.

DeckMapResolvedDatasetSchema, DeckMapDatasetSchemaState, isDeckMapGeneratedColumn, createDeckMapDatasetOutputSchemaSql, resolveDeckMapDatasetSchema, and useDeckMapDatasetSchema are all exported but lack tsdoc comments.

As per path instructions, "Add tsdoc to exported types and functions in @sqlrooms/* packages" for packages/**/*.{ts,tsx}.

Also applies to: 47-55, 57-80, 100-103

🤖 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/useDeckMapDatasetSchema.ts` around lines 19 - 33, Add tsdoc
comments to every new public export in this module so it follows the
`@sqlrooms/*` package rule for exported types and functions. Update the exported
symbols `DeckMapResolvedDatasetSchema`, `DeckMapDatasetSchemaState`,
`isDeckMapGeneratedColumn`, `createDeckMapDatasetOutputSchemaSql`,
`resolveDeckMapDatasetSchema`, and `useDeckMapDatasetSchema` with concise
documentation describing what each type/function represents and does, and keep
the comments directly above the corresponding declarations so they remain
attached even if the code moves.

Source: Path instructions

packages/deck/__tests__/useDeckMapDatasetSchema.test.ts (1)

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

Good coverage of the pure helpers; hook itself is untested.

The SQL-building and schema-resolution helper tests are thorough. However, useDeckMapDatasetSchema itself — with its non-trivial useEffect/AbortController/state-transition logic — has no direct test (e.g. via renderHook + a mocked useDuckDb connector) to verify loading/error/stale-request behavior.

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

🤖 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__/useDeckMapDatasetSchema.test.ts` around lines 1 - 92,
Add direct coverage for useDeckMapDatasetSchema itself, not just its pure
helpers, because its useEffect, AbortController, and state transitions are
currently untested. Create a hook test using renderHook with a mocked useDuckDb
connector to verify the loading, success, error, and stale-request/abort
behavior of useDeckMapDatasetSchema, alongside the existing helper coverage.

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/deck/src/MapSettings.tsx`:
- Around line 218-226: The `dataOutputColumns` fallback in `MapSettings` should
not reuse `outputColumns`, because that reintroduces generated/geometry-only
columns into selectors that should exclude them. Update the
`useDeckMapDatasetSchema` handling so `dataOutputColumns` stays empty (or
otherwise filtered to non-generated columns) when
`datasetSchema.dataOutputColumns` is empty, and make `firstColumnName` use the
same safe data-only set. Also surface `datasetSchema.isLoading` and
`datasetSchema.error` in this panel near the dependent field sections instead of
only gating on `outputColumns.length`, so schema loading/failure is visible
rather than silently hiding fields.

---

Nitpick comments:
In `@packages/deck/__tests__/useDeckMapDatasetSchema.test.ts`:
- Around line 1-92: Add direct coverage for useDeckMapDatasetSchema itself, not
just its pure helpers, because its useEffect, AbortController, and state
transitions are currently untested. Create a hook test using renderHook with a
mocked useDuckDb connector to verify the loading, success, error, and
stale-request/abort behavior of useDeckMapDatasetSchema, alongside the existing
helper coverage.

In `@packages/deck/src/dashboard.tsx`:
- Around line 180-222: The missing-column UI in DeckMapRuntimeIssuePanel
duplicates nearly the same JSX in the generated-column and generic branches.
Extract a shared render helper or small presentational component inside
dashboard.tsx and have the existing missingColumns/generatedMissingColumns
branches pass only the message text and column list so the layout stays
consistent and avoids future drift.

In `@packages/deck/src/mapLayerConfigUtils.ts`:
- Around line 326-338: Add a tsdoc comment for the exported function
setDeckMapLayerTimestampColumn in mapLayerConfigUtils so it matches the
documentation style used by setDeckMapLayerArcColumns and other exported APIs in
`@sqlrooms` packages. Keep the comment brief and describe that it updates the
selected deck map layer’s _sqlroomsBinding by setting timestampColumn while
preserving any existing binding fields.

In `@packages/deck/src/useDeckMapDatasetSchema.ts`:
- Around line 12-17: The generated-column detection in useDeckMapDatasetSchema
is relying on a hardcoded GENERATED_COLUMN_NAMES set, which can misclassify
legitimate columns like timestamps, source_geom, and target_geom. Update
resolveDeckMapDatasetSchema to use a single source of truth for
compiler-assigned aliases instead of duplicating literals here, and wire the
alias list from the same place that defines the geometry/H3/arc/trips compiler
output so the selector filtering stays in sync and avoids false positives.
- Around line 19-33: Add tsdoc comments to every new public export in this
module so it follows the `@sqlrooms/*` package rule for exported types and
functions. Update the exported symbols `DeckMapResolvedDatasetSchema`,
`DeckMapDatasetSchemaState`, `isDeckMapGeneratedColumn`,
`createDeckMapDatasetOutputSchemaSql`, `resolveDeckMapDatasetSchema`, and
`useDeckMapDatasetSchema` with concise documentation describing what each
type/function represents and does, and keep the comments directly above the
corresponding declarations so they remain attached even if the code moves.
🪄 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: 24a88c14-bf6a-4f4d-acd3-e9f8d636301a

📥 Commits

Reviewing files that changed from the base of the PR and between ae147e9 and c781229.

📒 Files selected for processing (5)
  • packages/deck/__tests__/useDeckMapDatasetSchema.test.ts
  • packages/deck/src/MapSettings.tsx
  • packages/deck/src/dashboard.tsx
  • packages/deck/src/mapLayerConfigUtils.ts
  • packages/deck/src/useDeckMapDatasetSchema.ts

Comment thread packages/deck/src/MapSettings.tsx Outdated
@ilyabo
ilyabo force-pushed the codex/generated-column-map-selector branch from c781229 to 9ff7ab4 Compare July 1, 2026 21:21

@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: 9ff7ab47b5

ℹ️ 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".

function arrowSchemaToTableColumns(table: arrow.Table): TableColumn[] {
return table.schema.fields.map((field) => ({
name: field.name,
type: String(field.type),

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 Map inspected Arrow types back to DuckDB types

For transformed table sources and pinned SQL, the settings panel now uses this inspected schema for dataOutputColumns, but String(field.type) produces Apache Arrow names such as Float64, Int32, and Utf8. The column selectors used for color and elevation filter by exact DuckDB type names (DOUBLE, INTEGER, VARCHAR, etc.), so numeric/text output columns from inspected datasets are filtered out and the selectors show no matching columns even though the query output has valid fields. This affects maps whose dataset source has transformSql or sqlQuery; convert Arrow types to the same DuckDB-style names used by table schemas before passing them to ColumnSelector.*.

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/deck/src/useDeckMapDatasetSchema.ts (2)

84-93: 📐 Maintainability & Code Quality | 🔵 Trivial

Duplicated transformSql-truthiness check.

shouldInspectOutputSchema's table-source branch and the classifyGeneratedColumns computation both independently re-derive isDeckMapDashboardTableDatasetSource(source) && source.transformSql?.trim(). Consider extracting a shared hasTableTransformSql(source) helper to avoid drift if the condition changes.
[recommended_refactor]

♻️ Proposed refactor
+function hasTableTransformSql(
+  source: DeckMapDashboardDatasetSource | undefined,
+): source is Pick<DeckTableDatasetInput, 'tableName' | 'transformSql'> {
+  return Boolean(
+    source &&
+      isDeckMapDashboardTableDatasetSource(source) &&
+      source.transformSql?.trim(),
+  );
+}

 function shouldInspectOutputSchema(
   source: DeckMapDashboardDatasetSource | undefined,
 ) {
   return Boolean(
     source &&
-    (isDeckMapDashboardSqlDatasetSource(source) ||
-      (isDeckMapDashboardTableDatasetSource(source) &&
-        source.transformSql?.trim())),
+    (isDeckMapDashboardSqlDatasetSource(source) || hasTableTransformSql(source)),
   );
 }
...
-        classifyGeneratedColumns:
-          isDeckMapDashboardTableDatasetSource(options.source) &&
-          Boolean(options.source.transformSql?.trim()),
+        classifyGeneratedColumns: hasTableTransformSql(options.source),

Also applies to: 265-274

🤖 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/useDeckMapDatasetSchema.ts` around lines 84 - 93, The
transformSql truthiness check is duplicated between shouldInspectOutputSchema
and classifyGeneratedColumns, which risks the two branches drifting apart.
Extract a shared helper such as hasTableTransformSql(source) and use it in both
places, keeping the existing
isDeckMapDashboardTableDatasetSource/source.transformSql?.trim() logic in one
reusable location. Make sure the helper is referenced anywhere this condition is
needed so the table-source handling stays consistent.

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

Use Arrow’s typed guards here instead of structural casts. DataType.isInt and DataType.isTimestamp already narrow to Arrow’s Int_/Timestamp_ types, so these as {bitWidth...} / as {unit...} casts can be replaced with the corresponding Arrow types for safer typing and less brittle code.

🤖 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/useDeckMapDatasetSchema.ts` around lines 95 - 125, The
Arrow type mapping helpers are using brittle structural casts instead of Arrow’s
built-in typed guards. Update the logic in mapArrowIntTypeToDuckDb (and the
related timestamp path if present in useDeckMapDatasetSchema) to rely on
DataType.isInt/DataType.isTimestamp narrowing so you can access bitWidth/unit
from the proper Arrow Int_/Timestamp_ types without manual casts. Keep the
conversion behavior the same, but replace the unsafe type assertions with the
Arrow-typed values.
🤖 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/deck/src/useDeckMapDatasetSchema.ts`:
- Around line 19-29: Add TSDoc comments to every exported symbol in
useDeckMapDatasetSchema.ts, including DeckMapResolvedDatasetSchema,
DeckMapDatasetSchemaState, isDeckMapGeneratedColumn,
createDeckMapDatasetOutputSchemaSql, resolveDeckMapDatasetSchema,
arrowTypeToDuckDbColumnType, and useDeckMapDatasetSchema. Keep the comments
concise but descriptive, explaining each type/function’s purpose and behavior so
the exported API in this `@sqlrooms/`* package is documented consistently.

---

Nitpick comments:
In `@packages/deck/src/useDeckMapDatasetSchema.ts`:
- Around line 84-93: The transformSql truthiness check is duplicated between
shouldInspectOutputSchema and classifyGeneratedColumns, which risks the two
branches drifting apart. Extract a shared helper such as
hasTableTransformSql(source) and use it in both places, keeping the existing
isDeckMapDashboardTableDatasetSource/source.transformSql?.trim() logic in one
reusable location. Make sure the helper is referenced anywhere this condition is
needed so the table-source handling stays consistent.
- Around line 95-125: The Arrow type mapping helpers are using brittle
structural casts instead of Arrow’s built-in typed guards. Update the logic in
mapArrowIntTypeToDuckDb (and the related timestamp path if present in
useDeckMapDatasetSchema) to rely on DataType.isInt/DataType.isTimestamp
narrowing so you can access bitWidth/unit from the proper Arrow Int_/Timestamp_
types without manual casts. Keep the conversion behavior the same, but replace
the unsafe type assertions with the Arrow-typed values.
🪄 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: d19415ea-f17d-4ddc-914d-47435098b248

📥 Commits

Reviewing files that changed from the base of the PR and between c781229 and bbc308e.

📒 Files selected for processing (5)
  • packages/deck/__tests__/useDeckMapDatasetSchema.test.ts
  • packages/deck/src/MapSettings.tsx
  • packages/deck/src/dashboard.tsx
  • packages/deck/src/mapLayerConfigUtils.ts
  • packages/deck/src/useDeckMapDatasetSchema.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/deck/src/mapLayerConfigUtils.ts
  • packages/deck/tests/useDeckMapDatasetSchema.test.ts
  • packages/deck/src/dashboard.tsx
  • packages/deck/src/MapSettings.tsx

Comment thread packages/deck/src/useDeckMapDatasetSchema.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: 8768133b66

ℹ️ 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/MapSettings.tsx Outdated
Comment on lines +204 to +206
if (!activeLayerDatasetSource) return undefined;
if (!isDeckMapDashboardTableDatasetSource(activeLayerDatasetSource)) {
return activeLayerDatasetSource;

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 Fall back to the dashboard table when source is omitted

When a layer is bound to a dataset object that omits source, this returns undefined even if the dashboard has a selected table; resolveDeckMapDashboardDatasetSource explicitly supports that fallback, so those maps still render from dashboard.selectedTable. With the new schema hook, outputColumns/dataOutputColumns stay empty in that supported configuration, which hides or disables the geometry/H3/arc/color/elevation selectors even though the runtime dataset has columns. Build a direct table source from selectedDataTable before giving up here.

Useful? React with 👍 / 👎.

…n-map-selector

# Conflicts:
#	packages/deck/src/MapSettings.tsx
@ilyabo
ilyabo merged commit ba5178e into main Jul 3, 2026
3 checks passed
@ilyabo
ilyabo deleted the codex/generated-column-map-selector branch July 3, 2026 16:34
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