This is an automated email from the ASF dual-hosted git repository.

richardfogaca pushed a commit to branch 
fix/currency-column-dropdown-calculated-cols
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4e3da4e2dd8e4f2cc4582e5e7f47c93a1699e2a6
Author: richard <[email protected]>
AuthorDate: Mon Feb 2 22:48:15 2026 -0300

    fix(dataset-editor): include calculated columns in currency code dropdown
    
    The currency code column dropdown in the Dataset Editor only showed
    physical columns with type_generic === String, which excluded calculated
    columns because the backend does not resolve type metadata for them.
    Loosen the filter to also include columns with a truthy expression,
    so calculated columns (e.g. CASE statements mapping countries to
    currency codes) appear in the dropdown.
---
 .../DatasourceEditor/DatasourceEditor.jsx          |  7 ++++++-
 .../tests/DatasourceEditorCurrency.test.tsx        | 22 ++++++++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git 
a/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx
 
b/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx
index 242ab820a92..f37d3613686 100644
--- 
a/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx
+++ 
b/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx
@@ -1092,8 +1092,13 @@ class DatasourceEditor extends PureComponent {
       }));
 
     // Get string-type columns for the currency code dropdown
+    // Include calculated columns (identified by truthy expression) even when
+    // type_generic is unresolved, since the backend only populates type 
metadata
+    // for physical columns. Currency detection handles invalid codes 
gracefully.
     const stringColumns = allColumns
-      .filter(col => col.type_generic === GenericDataType.String)
+      .filter(
+        col => col.type_generic === GenericDataType.String || col.expression,
+      )
       .map(col => ({
         value: col.column_name,
         label: col.verbose_name || col.column_name,
diff --git 
a/superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorCurrency.test.tsx
 
b/superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorCurrency.test.tsx
index 445a47b087f..71f3bc002bd 100644
--- 
a/superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorCurrency.test.tsx
+++ 
b/superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorCurrency.test.tsx
@@ -138,7 +138,7 @@ test('changes currency symbol from USD to GBP', async () => 
{
   expect(updatedMetric?.currency?.symbolPosition).toBe('prefix');
 }, 60000);
 
-test('currency code column dropdown shows only string columns', async () => {
+test('currency code column dropdown shows string and calculated columns but 
excludes numeric columns', async () => {
   const baseProps = createProps();
   const testProps = {
     ...baseProps,
@@ -167,6 +167,18 @@ test('currency code column dropdown shows only string 
columns', async () => {
           groupby: false,
           column_name: 'amount',
         },
+        {
+          id: 102,
+          type: null,
+          type_generic: null,
+          filterable: true,
+          is_dttm: false,
+          is_active: true,
+          expression:
+            "CASE WHEN country = 'US' THEN 'USD' ELSE 'EUR' END",
+          groupby: true,
+          column_name: 'derived_currency',
+        },
         ...baseProps.datasource.columns,
       ],
     },
@@ -196,8 +208,14 @@ test('currency code column dropdown shows only string 
columns', async () => {
     expect(currencyCodeOption).toBeDefined();
   });
 
-  // Verify NUMERIC column is NOT available
+  // Verify CALCULATED column is available despite null type_generic
   const options = document.querySelectorAll('.ant-select-item-option');
+  const derivedCurrencyOption = Array.from(options).find(o =>
+    o.textContent?.includes('derived_currency'),
+  );
+  expect(derivedCurrencyOption).toBeDefined();
+
+  // Verify NUMERIC column is NOT available
   const amountOption = Array.from(options).find(o =>
     o.textContent?.includes('amount'),
   );

Reply via email to