diff --git a/webapp/packages/supersonic-fe/src/pages/SemanticModel/Datasource/components/ModelFieldForm.tsx b/webapp/packages/supersonic-fe/src/pages/SemanticModel/Datasource/components/ModelFieldForm.tsx index bf412100e6..50cfaa67b3 100644 --- a/webapp/packages/supersonic-fe/src/pages/SemanticModel/Datasource/components/ModelFieldForm.tsx +++ b/webapp/packages/supersonic-fe/src/pages/SemanticModel/Datasource/components/ModelFieldForm.tsx @@ -1,19 +1,19 @@ import React, { useState } from 'react'; -import { Table, Select, Checkbox, Input, Space, Tooltip, Form, Switch, Row, Col } from 'antd'; +import { Checkbox, Form, Input, Select, Space, Switch, Table, Tooltip } from 'antd'; import TableTitleTooltips from '../../components/TableTitleTooltips'; import { isUndefined } from 'lodash'; import { ExclamationCircleOutlined } from '@ant-design/icons'; import SqlEditor from '@/components/SqlEditor'; import { ISemantic } from '../../data'; import { - TYPE_OPTIONS, - DATE_FORMATTER, AGG_OPTIONS, - EnumDataSourceType, + DATE_FORMATTER, DATE_OPTIONS, DIM_OPTIONS, + EnumDataSourceType, EnumModelDataType, PARTITION_TIME_FORMATTER, + TYPE_OPTIONS, } from '../constants'; import styles from '../style.less'; @@ -90,8 +90,7 @@ const ModelFieldForm: React.FC = ({ dataIndex: 'type', width: 250, render: (_: any, record: FieldItem) => { - const type = fields.find((field) => field.bizName === record.bizName)?.type; - const classType = fields.find((field) => field.bizName === record.bizName)?.classType; + const { type, classType } = record; const selectTypeValue = [EnumModelDataType.DIMENSION].includes(classType) ? classType : type; @@ -229,13 +228,10 @@ const ModelFieldForm: React.FC = ({ ); } if (type === EnumDataSourceType.MEASURES) { - const agg = record.expr - ? fields.find((field) => field.expr === record.expr)?.agg - : undefined; return ( ); } - if (process.env.SHOW_TAG) { if (type === EnumDataSourceType.CATEGORICAL) { const isTag = fields.find((field) => field.bizName === record.bizName)?.isTag; @@ -299,10 +294,7 @@ const ModelFieldForm: React.FC = ({ } } if ([EnumDataSourceType.TIME, EnumDataSourceType.PARTITION_TIME].includes(type)) { - const dateFormat = fields.find((field) => field.bizName === record.bizName)?.dateFormat; - const timeGranularity = fields.find( - (field) => field.bizName === record.bizName, - )?.timeGranularity; + const { dateFormat, timeGranularity } = record; const dateFormatterOptions = type === EnumDataSourceType.PARTITION_TIME ? PARTITION_TIME_FORMATTER : DATE_FORMATTER;