Skip to content

Commit a5cb947

Browse files
authored
fix: Check for the getBaseTable API before calling it (#2168)
- If it's not available, just fallback to the getKeyTable API (which we were using before) - Tested against deephaven-core 0.35.1 ``` from deephaven import new_table x = new_table({ "Foo": [0, 1, 2, 0, 1, 2], "Bar": [4, 5, 6, 7, 8, 9]} ).partition_by(["Foo"]) ```
1 parent b741f4e commit a5cb947

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

packages/iris-grid/src/IrisGridPartitionedTableModel.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import MissingPartitionError, {
88
} from './MissingPartitionError';
99
import { PartitionedGridModelProvider } from './PartitionedGridModel';
1010

11+
type PartitionedTableWithBaseTable = DhType.PartitionedTable & {
12+
getBaseTable: () => DhType.Table;
13+
};
14+
15+
function isPartitionedTableWithBaseTable(
16+
partitionedTable: DhType.PartitionedTable
17+
): partitionedTable is PartitionedTableWithBaseTable {
18+
return (
19+
'getBaseTable' in partitionedTable &&
20+
typeof partitionedTable.getBaseTable === 'function'
21+
);
22+
}
23+
1124
class IrisGridPartitionedTableModel
1225
extends EmptyIrisGridModel
1326
implements PartitionedGridModelProvider
@@ -80,8 +93,11 @@ class IrisGridPartitionedTableModel
8093
}
8194

8295
async partitionBaseTable(): Promise<DhType.Table> {
83-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
84-
return (this.partitionedTable as any).getBaseTable();
96+
if (isPartitionedTableWithBaseTable(this.partitionedTable)) {
97+
return this.partitionedTable.getBaseTable();
98+
}
99+
// Fallback to the key table if the base table API is not available
100+
return this.partitionedTable.getKeyTable();
85101
}
86102

87103
async partitionMergedTable(): Promise<DhType.Table> {

0 commit comments

Comments
 (0)