Skip to content

fix(dataset-editor): Calculated columns excluded from Currency Code column dropdown #37620

Closed

Description

@richardfogaca

Bug description

Calculated columns (e.g., a CASE statement mapping countries to currency codes) do not appear in the Currency code column dropdown in the Dataset Editor, even though the dropdown is built from allColumns which includes both physical and calculated columns.

Root cause

In DatasourceEditor.jsx (line 1095–1096), the dropdown options are filtered to only include columns where type_generic === GenericDataType.String:

const stringColumns = allColumns
  .filter(col => col.type_generic === GenericDataType.String)
  .map(col => ({
    value: col.column_name,
    label: col.verbose_name || col.column_name,
  }));

Calculated columns have type_generic set to null because the backend's fetch_metadata() only resolves type information for physical columns — calculated columns are added back to the dataset without type resolution. This causes the strict equality check to exclude every calculated column from the dropdown.

Note: calculated columns that have their Data Type dropdown explicitly set (e.g. to STRING) do get type_generic resolved and already pass the filter. The bug only affects calculated columns where the user hasn't set a data type.

Expected behavior

Untyped calculated columns should appear in the Currency code column dropdown. Calculated columns explicitly typed as NUMERIC, BOOLEAN, or DATETIME should remain excluded.

Proposed fix

Include calculated columns whose type_generic is null (untyped), while excluding those the user explicitly typed as non-string:

const stringColumns = allColumns
  .filter(
    col =>
      col.type_generic === GenericDataType.String ||
      (col.expression && col.type_generic == null),
  )
  .map(col => ({
    value: col.column_name,
    label: col.verbose_name || col.column_name,
  }));

No backend changes are needed.

How to reproduce the bug

  1. Open a dataset in the Dataset Editor
  2. Go to the Calculated Columns tab and add a column (e.g., CASE WHEN country = 'US' THEN 'USD' ELSE 'EUR' END) without setting a Data Type
  3. Go back to the Settings tab and open the Currency code column dropdown
  4. Observe that the calculated column does not appear in the dropdown

Screenshots/recordings

No response

Superset version

master

Python version

Not applicable (frontend-only bug)

Node version

Not applicable

Browser

All

Additional context

  • The allColumns array at line 1084 correctly includes calculated columns (spread from databaseColumns and calculatedColumns)
  • Calculated columns are identified by having a truthy expression property (line 627–630 of the same file)
  • The downstream currency formatting already guards against invalid codes, so this change is safe

Activity

  1. dosubot commented on Feb 3, 2026

    @dosubot

    The root cause is that the Currency code column dropdown in the Dataset Editor only includes columns where type_generic === GenericDataType.String, which excludes calculated columns since their type_generic is null. Calculated columns are present in allColumns and can be identified by a truthy expression property, but the current filter misses them.

    Your proposed fix—to loosen the filter so it includes columns with either type_generic === GenericDataType.String or an expression—will resolve the issue and allow calculated columns to appear in the dropdown. This change is frontend-only, requires no backend updates, and is safe because the currency formatting logic already handles invalid or unresolved codes gracefully.

    Recent PRs and issues have focused on currency code column features and Dataset Editor improvements, but none have addressed this specific bug or filtering logic, so your change would be a new and needed improvement PR #36416 PR #37165.

    To reply, just mention @dosu.


    How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

    Chat with Dosu Open in Cursor Join Discord Share on X

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    #bugBug reportchange:frontendRequires changing the frontenddata:datasetRelated to dataset configurations

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions