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

Data Explorer: Do not send backend empty schema, data, profile requests #5170

Merged
merged 1 commit into from
Oct 25, 2024
Merged
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
2 changes: 1 addition & 1 deletion extensions/positron-duckdb/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ END`;
numRows = upperLimit - lowerLimit + 1;
}

// No column selectors case -- TODO: why is the backend even sending this?
// No column selectors case, do not error if we get a request like this
if (columnSelectors.length === 0) {
return { columns: [] };
} else if (numRows === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ export class DataExplorerClientInstance extends Disposable {
* @returns A promise that resolves to the table schema.
*/
async getSchema(columnIndices: Array<number>): Promise<TableSchema> {
if (columnIndices.length === 0) {
// Do not send backend requests for an empty selection
return { columns: [] };
}
return this.runBackendTask(
() => this._backendClient.getSchema(columnIndices),
() => ({ columns: [] })
Expand Down Expand Up @@ -365,6 +369,10 @@ export class DataExplorerClientInstance extends Disposable {
* @returns A Promise<TableData> that resolves when the operation is complete.
*/
async getDataValues(columns: Array<ColumnSelection>): Promise<TableData> {
if (columns.length === 0) {
// Do not send backend requests for an empty selection
return { columns: [] };
}
return this.runBackendTask(
() => this._backendClient.getDataValues(columns, this._dataFormatOptions),
() => ({ columns: [[]] })
Expand Down Expand Up @@ -395,6 +403,10 @@ export class DataExplorerClientInstance extends Disposable {
async getColumnProfiles(
profiles: Array<ColumnProfileRequest>
): Promise<Array<ColumnProfileResult>> {
if (profiles.length === 0) {
// Do not send backend a request if empty array passed
return [];
}
return this.runBackendTask(
async () => {
const callbackId = generateUuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,14 @@ export class TableDataCache extends Disposable {
}
}

// Load the column schemas we need to load.
const tableSchema = await this._dataExplorerClientInstance.getSchema(columnIndices);

// Clear the column schema cache, if we're supposed to.
if (invalidateColumnSchemaCache) {
this._columnSchemaCache.clear();
}

// Load the column schemas we need to load.
const tableSchema = await this._dataExplorerClientInstance.getSchema(columnIndices);

// Cache the column schemas that were returned.
for (let i = 0; i < tableSchema.columns.length; i++) {
// Get the column schema and compute the column index.
Expand Down Expand Up @@ -501,9 +501,6 @@ export class TableDataCache extends Disposable {
}
}

// Get the data values.
const tableData = await this._dataExplorerClientInstance.getDataValues(columnSelections);

// Get the row labels.
let rowLabels: ArraySelection | undefined;
if (!tableState.has_row_labels) {
Expand Down Expand Up @@ -556,6 +553,9 @@ export class TableDataCache extends Disposable {
this._dataColumnCache.clear();
}

// Get the data values
const tableData = await this._dataExplorerClientInstance.getDataValues(columnSelections);

// Update the data column cache.
for (let column = 0; column < tableData.columns.length; column++) {
// Get the column selection.
Expand Down