mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
fix: save columns reference from sqllab save datasets flow (#24248)
This commit is contained in:
@@ -122,10 +122,10 @@ describe('ResultSet', () => {
|
||||
expect(table).toBeInTheDocument();
|
||||
|
||||
const firstColumn = queryAllByText(
|
||||
mockedProps.query.results?.columns[0].name ?? '',
|
||||
mockedProps.query.results?.columns[0].column_name ?? '',
|
||||
)[0];
|
||||
const secondColumn = queryAllByText(
|
||||
mockedProps.query.results?.columns[1].name ?? '',
|
||||
mockedProps.query.results?.columns[1].column_name ?? '',
|
||||
)[0];
|
||||
expect(firstColumn).toBeInTheDocument();
|
||||
expect(secondColumn).toBeInTheDocument();
|
||||
|
||||
@@ -205,7 +205,7 @@ const ResultSet = ({
|
||||
...EXPLORE_CHART_DEFAULT,
|
||||
datasource: `${results.query_id}__query`,
|
||||
...{
|
||||
all_columns: results.columns.map(column => column.name),
|
||||
all_columns: results.columns.map(column => column.column_name),
|
||||
},
|
||||
});
|
||||
const url = mountExploreUrl(null, {
|
||||
@@ -491,7 +491,7 @@ const ResultSet = ({
|
||||
}
|
||||
if (data && data.length > 0) {
|
||||
const expandedColumns = results.expanded_columns
|
||||
? results.expanded_columns.map(col => col.name)
|
||||
? results.expanded_columns.map(col => col.column_name)
|
||||
: [];
|
||||
return (
|
||||
<>
|
||||
@@ -500,7 +500,7 @@ const ResultSet = ({
|
||||
{sql}
|
||||
<FilterableTable
|
||||
data={data}
|
||||
orderedColumnKeys={results.columns.map(col => col.name)}
|
||||
orderedColumnKeys={results.columns.map(col => col.column_name)}
|
||||
height={rowsHeight}
|
||||
filterText={searchText}
|
||||
expandedColumns={expandedColumns}
|
||||
|
||||
@@ -62,6 +62,7 @@ export type ExploreQuery = QueryResponse & {
|
||||
|
||||
export interface ISimpleColumn {
|
||||
column_name?: string | null;
|
||||
name?: string | null;
|
||||
type?: string | null;
|
||||
is_dttm?: boolean | null;
|
||||
}
|
||||
@@ -199,14 +200,15 @@ export const SaveDatasetModal = ({
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
|
||||
const [, key] = await Promise.all([
|
||||
updateDataset(
|
||||
datasource?.dbId,
|
||||
datasetToOverwrite?.datasetid,
|
||||
datasource?.sql,
|
||||
datasource?.columns?.map(
|
||||
(d: { name: string; type: string; is_dttm: boolean }) => ({
|
||||
column_name: d.name,
|
||||
(d: { column_name: string; type: string; is_dttm: boolean }) => ({
|
||||
column_name: d.column_name,
|
||||
type: d.type,
|
||||
is_dttm: d.is_dttm,
|
||||
}),
|
||||
@@ -292,12 +294,10 @@ export const SaveDatasetModal = ({
|
||||
|
||||
dispatch(
|
||||
createDatasource({
|
||||
schema: datasource.schema,
|
||||
sql: datasource.sql,
|
||||
dbId: datasource.dbId || datasource?.database?.id,
|
||||
templateParams,
|
||||
datasourceName: datasetName,
|
||||
columns: selectedColumns,
|
||||
}),
|
||||
)
|
||||
.then((data: { id: number }) =>
|
||||
|
||||
@@ -236,24 +236,24 @@ export const queries = [
|
||||
columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'gender',
|
||||
column_name: 'gender',
|
||||
type: 'STRING',
|
||||
},
|
||||
],
|
||||
selected_columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'gender',
|
||||
column_name: 'gender',
|
||||
type: 'STRING',
|
||||
},
|
||||
],
|
||||
@@ -326,7 +326,7 @@ export const queryWithNoQueryLimit = {
|
||||
columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
@@ -338,12 +338,12 @@ export const queryWithNoQueryLimit = {
|
||||
selected_columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'gender',
|
||||
column_name: 'gender',
|
||||
type: 'STRING',
|
||||
},
|
||||
],
|
||||
@@ -364,57 +364,57 @@ export const queryWithBadColumns = {
|
||||
selected_columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'COUNT(*)',
|
||||
column_name: 'COUNT(*)',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'this_col_is_ok',
|
||||
column_name: 'this_col_is_ok',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'a',
|
||||
column_name: 'a',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: '1',
|
||||
column_name: '1',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: '123',
|
||||
column_name: '123',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'CASE WHEN 1=1 THEN 1 ELSE 0 END',
|
||||
column_name: 'CASE WHEN 1=1 THEN 1 ELSE 0 END',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: true,
|
||||
name: '_TIMESTAMP',
|
||||
column_name: '_TIMESTAMP',
|
||||
type: 'TIMESTAMP',
|
||||
},
|
||||
{
|
||||
is_dttm: true,
|
||||
name: '__TIME',
|
||||
column_name: '__TIME',
|
||||
type: 'TIMESTAMP',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'my_dupe_col__2',
|
||||
column_name: 'my_dupe_col__2',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: true,
|
||||
name: '__timestamp',
|
||||
column_name: '__timestamp',
|
||||
type: 'TIMESTAMP',
|
||||
},
|
||||
{
|
||||
is_dttm: true,
|
||||
name: '__TIMESTAMP',
|
||||
column_name: '__TIMESTAMP',
|
||||
type: 'TIMESTAMP',
|
||||
},
|
||||
],
|
||||
@@ -572,31 +572,31 @@ const baseQuery: QueryResponse = {
|
||||
columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'gender',
|
||||
column_name: 'gender',
|
||||
type: 'STRING',
|
||||
},
|
||||
],
|
||||
selected_columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
{
|
||||
is_dttm: false,
|
||||
name: 'gender',
|
||||
column_name: 'gender',
|
||||
type: 'STRING',
|
||||
},
|
||||
],
|
||||
expanded_columns: [
|
||||
{
|
||||
is_dttm: true,
|
||||
name: 'ds',
|
||||
column_name: 'ds',
|
||||
type: 'STRING',
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user