You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2026/03/24 14:27:16 UTC
(superset) 04/08: fix(explore): display actual data type instead of "column" in column tooltip (#38554)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 6.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 11b510ecadb433dc7d1abe7f6a21bc7a18a4799c
Author: Levis Mbote <11...@users.noreply.github.com>
AuthorDate: Mon Mar 23 19:06:54 2026 +0300
fix(explore): display actual data type instead of "column" in column tooltip (#38554)
(cherry picked from commit e67bc5bee59ccd53841ef1a641f675249dc61fa3)
---
.../src/components/ColumnOption.tsx | 2 +-
.../src/components/labelUtils.tsx | 23 ++++++++++++++++++++--
.../test/components/labelUtils.test.tsx | 19 ++++++++++++++++++
3 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx
index ca3c9edb164..17f02eecbd5 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/ColumnOption.tsx
@@ -59,7 +59,7 @@ export function ColumnOption({
const type = hasExpression ? 'expression' : type_generic;
const [tooltipText, setTooltipText] = useState<ReactNode>(column.column_name);
const [columnTypeTooltipText, setcolumnTypeTooltipText] = useState<ReactNode>(
- column.type,
+ getColumnTypeTooltipNode(column),
);
useLayoutEffect(() => {
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/components/labelUtils.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/components/labelUtils.tsx
index d4a1aec7fe7..ffee313a4df 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/components/labelUtils.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/components/labelUtils.tsx
@@ -20,6 +20,7 @@ import { ReactNode, RefObject } from 'react';
import { t } from '@apache-superset/core/translation';
import { css, styled } from '@apache-superset/core/theme';
+import { GenericDataType } from '@apache-superset/core/common';
import { ColumnMeta, Metric } from '@superset-ui/chart-controls';
const TooltipSectionWrapper = styled.div`
@@ -64,11 +65,29 @@ export const getColumnLabelText = (column: ColumnMeta): string =>
column.verbose_name || column.column_name;
export const getColumnTypeTooltipNode = (column: ColumnMeta): ReactNode => {
- if (!column.type) {
+ const rawType = typeof column.type === 'string' ? column.type.trim() : '';
+
+ let typeLabel: ReactNode | null = null;
+
+ if (rawType && rawType.toLowerCase() !== 'column') {
+ typeLabel = rawType;
+ } else if (typeof column.type_generic === 'number') {
+ if (column.type_generic === GenericDataType.String) {
+ typeLabel = t('string');
+ } else if (column.type_generic === GenericDataType.Numeric) {
+ typeLabel = t('numeric');
+ } else if (column.type_generic === GenericDataType.Temporal) {
+ typeLabel = t('timestamp');
+ } else if (column.type_generic === GenericDataType.Boolean) {
+ typeLabel = t('boolean');
+ }
+ }
+
+ if (!typeLabel) {
return null;
}
- return <TooltipSection label={t('Column type')} text={column.type} />;
+ return <TooltipSection label={t('Column type')} text={typeLabel} />;
};
export const getColumnTooltipNode = (
diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx b/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx
index 64e75887abd..ae050c820ed 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/test/components/labelUtils.test.tsx
@@ -24,6 +24,7 @@ import {
getMetricTooltipNode,
getColumnTypeTooltipNode,
} from '../../src/components/labelUtils';
+import { GenericDataType } from '@apache-superset/core/common';
test("should get column name when column doesn't have verbose_name", () => {
expect(
@@ -89,6 +90,24 @@ test('should get column datatype rendered as tooltip when column has a type', ()
expect(screen.getByText('text')).toBeVisible();
});
+test('should fall back to generic data type label when type is "column"', () => {
+ render(
+ <>
+ {getColumnTypeTooltipNode({
+ id: 123,
+ column_name: 'column name',
+ verbose_name: '',
+ description: '',
+ type: 'column',
+ type_generic: GenericDataType.String,
+ })}
+ </>,
+ );
+
+ expect(screen.getByText('Column type')).toBeVisible();
+ expect(screen.getByText('string')).toBeVisible();
+});
+
test('should get column name, verbose name and description when it has a verbose name', () => {
const ref = { current: { scrollWidth: 100, clientWidth: 100 } };
render(