Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DH-17242: Partition Table Pickers not partitioning table properly #2096

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/iris-grid/src/IrisGridPartitionSelector.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
}
.partition-button-group {
display: flex;
border: 1px var(--dh-color-hr);
border-style: none solid;
padding: 0 $spacer-2;
border-right: 1px solid var(--dh-color-hr);
padding-right: $spacer-2;
gap: $spacer-2;
}
}
23 changes: 9 additions & 14 deletions packages/iris-grid/src/IrisGridPartitionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,13 @@ class IrisGridPartitionSelector extends Component<
index: number,
selectedValue: unknown
): Promise<void> {
const { model, partitionConfig: prevConfig } = this.props;
const { partitionConfig: prevConfig } = this.props;

log.debug('handlePartitionSelect', index, selectedValue, prevConfig);

const newPartitions = [...prevConfig.partitions];
newPartitions[index] = selectedValue;

// If it's the last partition changed, we know it's already a valid value, just emit it
if (index === model.partitionColumns.length - 1) {
this.sendUpdate({ partitions: newPartitions, mode: 'partition' });
return;
}

const { keysTable } = this.state;
// Otherwise, we need to get the value from a filtered key table
assertNotNull(keysTable);
Expand All @@ -184,7 +178,7 @@ class IrisGridPartitionSelector extends Component<
// Core JSAPI returns undefined for null table values,
// coalesce with null to differentiate null from no selection in the dropdown
// https://github.com/deephaven/deephaven-core/issues/5400
partitions: t.columns.map(column => data.rows[0].get(column) ?? null),
partitions: t.columns.map(column => data.rows[0].get(column)),
mode: 'partition',
};
t.close();
Expand Down Expand Up @@ -294,13 +288,15 @@ class IrisGridPartitionSelector extends Component<
const { model, partitionConfig } = this.props;
const { isLoading, partitionFilters, partitionTables } = this.state;

const { partitions } = partitionConfig;

if (partitionFilters !== null && partitionTables !== null) {
partitionFilters.forEach((filter, index) => {
partitionTables[index].applyFilter(filter as dh.FilterCondition[]);
// Have to set viewport since it is cleared after making selection in picker
// setting it to 50 to avoid loading all the data, but sufficient for most datasets for initial render
partitionTables[index].setViewport(0, 50);
});
}

const partitionSelectors = model.partitionColumns.map((column, index) => (
<div key={`selector-${column.name}`} className="column-selector">
{partitionTables?.[index] && (
Expand All @@ -311,10 +307,10 @@ class IrisGridPartitionSelector extends Component<
direction="bottom"
shouldFlip={false}
keyColumn={partitionTables[index].columns[index].name}
selectedKey={partitionConfig.partitions[index] as ItemKey}
placeholder={'Loading...' as string}
labelColumn={partitionTables[index].columns[index].name}
onChange={this.getCachedChangeCallback(index)}
defaultSelectedKey={partitions[index] as ItemKey}
isDisabled={
(index > 0 && partitionConfig.mode !== 'partition') || isLoading
}
Expand All @@ -327,7 +323,6 @@ class IrisGridPartitionSelector extends Component<
));
return (
<div className="iris-grid-partition-selector">
<div className="table-name">Partitioned Table</div>
<div className="partition-button-group">
<Button
onClick={this.handleKeyTableClick}
Expand All @@ -337,7 +332,7 @@ class IrisGridPartitionSelector extends Component<
active={partitionConfig.mode === 'keys'}
disabled={isLoading}
>
Keys
Partitions
</Button>
<Button
onClick={this.handleMergeClick}
Expand All @@ -347,7 +342,7 @@ class IrisGridPartitionSelector extends Component<
active={partitionConfig.mode === 'merged'}
disabled={isLoading}
>
Merge
{model.isPartitionRequired ? 'Merge' : 'Coalesce'}
</Button>
</div>
{partitionSelectors}
Expand Down
Loading