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

feat: Add support for multi-partition parquet:kv tables #1580

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add legacy format for dehydrated state
georgecwan committed Oct 25, 2023
commit a6d31a17a68f88c2f67920409451b0c8c34fe273
Original file line number Diff line number Diff line change
@@ -321,7 +321,7 @@ class MockIrisGridTreeModel
throw new Error('Not defined in mock');
}

valuesTable(columns: Column[]): Promise<never> {
valuesTable(columns: Column | Column[]): Promise<never> {
throw new Error('Not defined in mock');
}

18 changes: 8 additions & 10 deletions packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ import {
IrisGridState,
ChartBuilderSettings,
DehydratedIrisGridState,
DehydratedIrisGridPanelState,
ColumnHeaderGroup,
IrisGridContextMenuData,
IrisGridTableModel,
@@ -114,23 +115,20 @@ export interface PanelState {
movedRows: MoveOperation[];
};
irisGridState: DehydratedIrisGridState;
irisGridPanelState: {
partitionColumns: ColumnName[];
partitions: (string | null)[];
isSelectingPartition: boolean;
advancedSettings: [AdvancedSettingsType, boolean][];
};
irisGridPanelState: DehydratedIrisGridPanelState;
pluginState: unknown;
}

// Some of the properties in the loaded panel state may be omitted
// even though they can't be undefined in the dehydrated state.
// This can happen when loading the state saved before the properties were added.
type LoadedPanelState = PanelState & {
irisGridPanelState: PanelState['irisGridPanelState'] &
Partial<
Pick<PanelState['irisGridPanelState'], 'partitions' | 'partitionColumns'>
>;
irisGridPanelState: PanelState['irisGridPanelState'] & {
partitions?: (string | null)[];
partitionColumns?: ColumnName[];
partition?: string | null;
partitionColumn?: ColumnName;
};
};

export interface IrisGridPanelProps extends DashboardPanelProps {
6 changes: 1 addition & 5 deletions packages/iris-grid/src/IrisGridPartitionSelector.tsx
Original file line number Diff line number Diff line change
@@ -132,18 +132,14 @@ class IrisGridPartitionSelector<T> extends Component<
}

handlePartitionSelect(index: number, partition: string): void {
const { columns } = this.props;
const { partitions, partitionTables } = this.state;
const selectedMenu = this.searchMenu[index];
if (selectedMenu) {
selectedMenu.closeMenu();
}

const newPartitions = [...partitions];
newPartitions[index] =
TableUtils.isCharType(columns[index].type) && partition.length > 0
? partition.charCodeAt(0).toString()
: partition;
newPartitions[index] = partition;
if (partitionTables) {
this.updatePartitionFilters(newPartitions, partitionTables);
}
73 changes: 49 additions & 24 deletions packages/iris-grid/src/IrisGridUtils.ts
Original file line number Diff line number Diff line change
@@ -143,6 +143,38 @@ export interface DehydratedIrisGridState {
columnHeaderGroups?: readonly ColumnGroup[];
}

export interface DehydratedIrisGridPanelStateV1 {
isSelectingPartition: boolean;
partition: string | null;
partitionColumn: ColumnName;
advancedSettings: [AdvancedSettingsType, boolean][];
}

export interface DehydratedIrisGridPanelStateV2 {
isSelectingPartition: boolean;
partitions: (string | null)[];
partitionColumns: ColumnName[];
advancedSettings: [AdvancedSettingsType, boolean][];
}

export type DehydratedIrisGridPanelState =
| DehydratedIrisGridPanelStateV1
| DehydratedIrisGridPanelStateV2;

export function isPanelStateV1(
state: DehydratedIrisGridPanelState
): state is DehydratedIrisGridPanelStateV1 {
return (state as DehydratedIrisGridPanelStateV1).partitionColumn != null;
}

export function isPanelStateV2(
state: DehydratedIrisGridPanelState
): state is DehydratedIrisGridPanelStateV2 {
return Array.isArray(
(state as DehydratedIrisGridPanelStateV2).partitionColumns
);
}

/**
* Checks if an index is valid for the given array
* @param x The index to check
@@ -279,12 +311,7 @@ class IrisGridUtils {
partitionColumns: Column[];
advancedSettings: Map<AdvancedSettingsType, boolean>;
}
): {
isSelectingPartition: boolean;
partitions: (string | null)[];
partitionColumns: ColumnName[];
advancedSettings: [AdvancedSettingsType, boolean][];
} {
): DehydratedIrisGridPanelState {
const {
isSelectingPartition,
partitions,
@@ -311,25 +338,21 @@ class IrisGridUtils {
*/
static hydrateIrisGridPanelState(
model: IrisGridModel,
irisGridPanelState: {
// This needs to be changed after IrisGridPanel is done
isSelectingPartition: boolean;
partitions: (string | null)[];
partitionColumns: ColumnName[];
advancedSettings: [AdvancedSettingsType, boolean][];
}
irisGridPanelState: DehydratedIrisGridPanelState
): {
isSelectingPartition: boolean;
partitions: (string | null)[];
partitionColumns: Column[];
advancedSettings: Map<AdvancedSettingsType, boolean>;
} {
const {
isSelectingPartition,
partitions,
partitionColumns,
advancedSettings,
} = irisGridPanelState;
const { isSelectingPartition, advancedSettings } = irisGridPanelState;

const { partitionColumns, partitions } = isPanelStateV2(irisGridPanelState)
? irisGridPanelState
: {
partitionColumns: [irisGridPanelState.partitionColumn],
partitions: [irisGridPanelState.partition],
};

const { columns } = model;
return {
@@ -391,10 +414,7 @@ class IrisGridUtils {
static extractTableSettings<AF, QF, S>(
panelState: {
irisGridState: { advancedFilters: AF; quickFilters: QF; sorts: S };
irisGridPanelState: {
partitionColumns: ColumnName[];
partitions: unknown[];
};
irisGridPanelState: DehydratedIrisGridPanelState;
},
inputFilters: InputFilter[] = []
): {
@@ -406,7 +426,12 @@ class IrisGridUtils {
sorts: S;
} {
const { irisGridPanelState, irisGridState } = panelState;
const { partitionColumns, partitions } = irisGridPanelState;
const { partitionColumns, partitions } = isPanelStateV2(irisGridPanelState)
? irisGridPanelState
: {
partitionColumns: [irisGridPanelState.partitionColumn],
partitions: [irisGridPanelState.partition],
};
const { advancedFilters, quickFilters, sorts } = irisGridState;

return {