mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
chore(native-filters): Fetch only the required dataset fields (#23303)
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
parent
3277ea83ea
commit
ffc0a81e85
@ -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: [
|
||||
@ -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: [
|
||||
@ -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',
|
||||
|
@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React, { useCallback, useState, useMemo, useEffect } from 'react';
|
||||
import rison from 'rison';
|
||||
import { Column, ensureIsArray, t, useChangeEffect } from '@superset-ui/core';
|
||||
import { Select, FormInstance } from 'src/components';
|
||||
import { useToasts } from 'src/components/MessageToasts/withToasts';
|
||||
@ -85,7 +86,13 @@ export function ColumnSelect({
|
||||
}
|
||||
if (datasetId != null) {
|
||||
cachedSupersetGet({
|
||||
endpoint: `/api/v1/dataset/${datasetId}`,
|
||||
endpoint: `/api/v1/dataset/${datasetId}?q=${rison.encode({
|
||||
columns: [
|
||||
'columns.column_name',
|
||||
'columns.is_dttm',
|
||||
'columns.type_generic',
|
||||
],
|
||||
})}`,
|
||||
}).then(
|
||||
({ json: { result } }) => {
|
||||
const lookupValue = Array.isArray(value) ? value : [value];
|
||||
|
@ -45,6 +45,7 @@ import React, {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import rison from 'rison';
|
||||
import { PluginFilterSelectCustomizeProps } from 'src/filters/components/Select/types';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getChartDataRequest } from 'src/components/Chart/chartAction';
|
||||
@ -654,7 +655,28 @@ const FiltersConfigForm = (
|
||||
useEffect(() => {
|
||||
if (datasetId) {
|
||||
cachedSupersetGet({
|
||||
endpoint: `/api/v1/dataset/${datasetId}`,
|
||||
endpoint: `/api/v1/dataset/${datasetId}?q=${rison.encode({
|
||||
columns: [
|
||||
'columns.column_name',
|
||||
'columns.expression',
|
||||
'columns.filterable',
|
||||
'columns.is_dttm',
|
||||
'columns.type',
|
||||
'columns.verbose_name',
|
||||
'database.id',
|
||||
'database.database_name',
|
||||
'datasource_type',
|
||||
'filter_select_enabled',
|
||||
'id',
|
||||
'is_sqllab_view',
|
||||
'main_dttm_col',
|
||||
'metrics.metric_name',
|
||||
'metrics.verbose_name',
|
||||
'schema',
|
||||
'sql',
|
||||
'table_name',
|
||||
],
|
||||
})}`,
|
||||
})
|
||||
.then((response: JsonResponse) => {
|
||||
setMetrics(response.json?.result?.metrics);
|
||||
|
Loading…
Reference in New Issue
Block a user