Skip to content

Commit

Permalink
chore(native-filters): Fetch only the dataset columns
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley committed Mar 7, 2023
1 parent f7e7652 commit 1b53e5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Column, JsonObject } from '@superset-ui/core';
import userEvent from '@testing-library/user-event';
import { ColumnSelect } from './ColumnSelect';

fetchMock.get('glob:*/api/v1/dataset/123', {
fetchMock.get('glob:*/api/v1/dataset/123?*', {
body: {
result: {
columns: [
Expand All @@ -35,7 +35,7 @@ fetchMock.get('glob:*/api/v1/dataset/123', {
},
},
});
fetchMock.get('glob:*/api/v1/dataset/456', {
fetchMock.get('glob:*/api/v1/dataset/456?*', {
body: {
result: {
columns: [
Expand All @@ -47,7 +47,7 @@ fetchMock.get('glob:*/api/v1/dataset/456', {
},
});

fetchMock.get('glob:*/api/v1/dataset/789', { status: 404 });
fetchMock.get('glob:*/api/v1/dataset/789?*', { status: 404 });

const createProps = (extraProps: JsonObject = {}) => ({
filterId: 'filterId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import React, { useCallback, useState, useMemo, useEffect } from 'react';
import rison from 'rison';
import { Column, ensureIsArray, SupersetClient, t } from '@superset-ui/core';
import { useChangeEffect } from 'src/hooks/useChangeEffect';
import { Select, FormInstance } from 'src/components';
Expand Down Expand Up @@ -98,7 +99,26 @@ export function ColumnSelect({
}
if (datasetId != null) {
cachedSupersetGet({
endpoint: `/api/v1/dataset/${datasetId}`,
endpoint: `/api/v1/dataset/${datasetId}?q=${rison.encode({
columns: [
'columns.advanced_data_type',
'columns.changed_on',
'columns.column_name',
'columns.created_on',
'columns.description',
'columns.expression',
'columns.filterable',
'columns.groupby',
'columns.id',
'columns.is_active',
'columns.extra',
'columns.is_dttm',
'columns.python_date_format',
'columns.type',
'columns.uuid',
'columns.verbose_name',
],
})}`,
}).then(
({ json: { result } }) => {
const lookupValue = Array.isArray(value) ? value : [value];
Expand Down

0 comments on commit 1b53e5d

Please sign in to comment.