fix: failed samples should throw exception (#20228)

This commit is contained in:
Yongjie Zhao
2022-06-01 18:24:01 +08:00
committed by GitHub
parent 9432c62ec1
commit 1530c34792
5 changed files with 85 additions and 12 deletions

View File

@@ -17,7 +17,7 @@
* under the License.
*/
import React, { useState, useEffect, useMemo } from 'react';
import { GenericDataType, styled, t } from '@superset-ui/core';
import { ensureIsArray, GenericDataType, styled, t } from '@superset-ui/core';
import Loading from 'src/components/Loading';
import { EmptyStateMedium } from 'src/components/EmptyState';
import TableView, { EmptyWrapperType } from 'src/components/TableView';
@@ -63,9 +63,9 @@ export const SamplesPane = ({
setIsLoading(true);
getDatasetSamples(datasource.id, queryForce)
.then(response => {
setData(response.data);
setColnames(response.colnames);
setColtypes(response.coltypes);
setData(ensureIsArray(response.data));
setColnames(ensureIsArray(response.colnames));
setColtypes(ensureIsArray(response.coltypes));
setResponseError('');
cache.add(datasource);
if (queryForce && actions) {
@@ -73,6 +73,9 @@ export const SamplesPane = ({
}
})
.catch(error => {
setData([]);
setColnames([]);
setColtypes([]);
setResponseError(`${error.name}: ${error.message}`);
})
.finally(() => {