From 9a5a20fb9eb00b5b630afd0226e153a1f6fd6041 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Wed, 4 Oct 2023 14:18:41 -0700 Subject: [PATCH] Load table fields for acceleration index flyout (#137) * load table fields after table is selected Signed-off-by: Shenoy Pratik * simplify the map function Signed-off-by: Shenoy Pratik --------- Signed-off-by: Shenoy Pratik --- .../selectors/index_type_selector.tsx | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/public/components/acceleration/selectors/index_type_selector.tsx b/public/components/acceleration/selectors/index_type_selector.tsx index 1e195c8f..5c8c9bca 100644 --- a/public/components/acceleration/selectors/index_type_selector.tsx +++ b/public/components/acceleration/selectors/index_type_selector.tsx @@ -18,7 +18,11 @@ import { ACCELERATION_INDEX_TYPES, ACC_INDEX_TYPE_DOCUMENTATION_URL, } from '../../../../common/constants'; -import { AccelerationIndexType, CreateAccelerationForm } from '../../../../common/types'; +import { + AccelerationIndexType, + CreateAccelerationForm, + DataTableFieldsType, +} from '../../../../common/types'; import { getJobId, pollQueryStatus } from '../../SQLPage/utils'; interface IndexTypeSelectorProps { @@ -48,22 +52,14 @@ export const IndexTypeSelector = ({ }; getJobId(query, http, (id: string) => { pollQueryStatus(id, http, (data: any[]) => { + const dataTableFields: DataTableFieldsType[] = data.map((field, index) => ({ + id: `${idPrefix}${index + 1}`, + fieldName: field.col_name, + dataType: field.data_type, + })); setAccelerationFormData({ ...accelerationFormData, - dataTableFields: [ - { id: `${idPrefix}1`, fieldName: 'Field1', dataType: 'Integer' }, - { id: `${idPrefix}2`, fieldName: 'Field2', dataType: 'Integer' }, - { id: `${idPrefix}3`, fieldName: 'Field3', dataType: 'Integer' }, - { id: `${idPrefix}4`, fieldName: 'Field4', dataType: 'Integer' }, - { id: `${idPrefix}5`, fieldName: 'Field5', dataType: 'Integer' }, - { id: `${idPrefix}6`, fieldName: 'Field6', dataType: 'Integer' }, - { id: `${idPrefix}7`, fieldName: 'Field7', dataType: 'Integer' }, - { id: `${idPrefix}8`, fieldName: 'Field8', dataType: 'Integer' }, - { id: `${idPrefix}9`, fieldName: 'Field9', dataType: 'Integer' }, - { id: `${idPrefix}10`, fieldName: 'Field10', dataType: 'Integer' }, - { id: `${idPrefix}11`, fieldName: 'Field11', dataType: 'Integer' }, - { id: `${idPrefix}12`, fieldName: 'Field12', dataType: 'TimestampType' }, - ], + dataTableFields: dataTableFields, }); setLoading(false); });