From bf7856b5c2a302dc3151ecf4cf840593804391b4 Mon Sep 17 00:00:00 2001 From: mikebender Date: Thu, 12 Dec 2024 10:15:46 -0500 Subject: [PATCH] fix: Allow double and float types to be rollupable - We had this restriction in the UI, but the engine can actually handle it - Tested with doubles, floats - Tested with the following tables: ```python from deephaven import empty_table doubles = empty_table(1_000_000).update_view(["Group = i*10.4", "N = (i % 347)*0.1", "M = (i % 29)*10.2", "Value=i*2.4", "Weight=i*4.2"]) floats = empty_table(1_000_000).update_view(["Group = i*10.4", "N = (float)(i % 347)*0.1", "M = (float)(i % 29)*10.2", "Value=(float)i*2.4", "Weight=(float)i*4.2"]) ``` - Updated e2e tests and unit tests --- .../iris-grid/src/sidebar/RollupRows.test.tsx | 21 +++++++++++++++++++ packages/iris-grid/src/sidebar/RollupRows.tsx | 5 ++++- tests/table-operations.spec.ts | 12 +++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 packages/iris-grid/src/sidebar/RollupRows.test.tsx diff --git a/packages/iris-grid/src/sidebar/RollupRows.test.tsx b/packages/iris-grid/src/sidebar/RollupRows.test.tsx new file mode 100644 index 0000000000..296809f7b9 --- /dev/null +++ b/packages/iris-grid/src/sidebar/RollupRows.test.tsx @@ -0,0 +1,21 @@ +import { type dh as DhType } from '@deephaven/jsapi-types'; +import { TestUtils } from '@deephaven/test-utils'; +import RollupRows from './RollupRows'; + +it('should allow all column types to be groupable', () => { + function testType(type: string, expected = true) { + const column = TestUtils.createMockProxy({ type }); + expect(RollupRows.isGroupable(column)).toBe(expected); + } + + testType('string'); + testType('int'); + testType('long'); + testType('float'); + testType('double'); + testType('java.lang.String'); + testType('java.lang.Integer'); + testType('java.lang.Long'); + testType('java.math.BigDecimal', false); + testType('java.math.BigInteger', false); +}); diff --git a/packages/iris-grid/src/sidebar/RollupRows.tsx b/packages/iris-grid/src/sidebar/RollupRows.tsx index d31f5e5544..b93c8aa479 100644 --- a/packages/iris-grid/src/sidebar/RollupRows.tsx +++ b/packages/iris-grid/src/sidebar/RollupRows.tsx @@ -115,7 +115,10 @@ class RollupRows extends Component { } static isGroupable(column: dh.Column): boolean { - return !TableUtils.isDecimalType(column.type); + return ( + !TableUtils.isBigDecimalType(column.type) && + !TableUtils.isBigIntegerType(column.type) + ); } constructor(props: RollupRowsProps) { diff --git a/tests/table-operations.spec.ts b/tests/table-operations.spec.ts index 8f2f9bbfe7..566c4ad168 100644 --- a/tests/table-operations.spec.ts +++ b/tests/table-operations.spec.ts @@ -470,6 +470,18 @@ test('rollup rows and aggregrate columns', async ({ page }) => { await expect(page.locator('.iris-grid-column')).toHaveScreenshot(); }); + await test.step('Rollup a double column', async () => { + const doubleColumn = page.getByRole('button', { + name: 'Double', + exact: true, + }); + expect(doubleColumn).toBeTruthy(); + await doubleColumn.dblclick(); + + await waitForLoadingDone(page); + await expect(page.locator('.iris-grid-column')).toHaveScreenshot(); + }); + await test.step('Aggregate columns', async () => { await page.getByText('Constituents').click(); await page.getByText('Non-Aggregated Columns').click();