mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-20 05:26:57 +08:00
Compare commits
3 Commits
cc66ebd684
...
4ab9cd715d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ab9cd715d | ||
|
|
fd306db3fe | ||
|
|
30adaa3f20 |
@@ -12,6 +12,7 @@ public class QueryColumn {
|
||||
private String name;
|
||||
private String type;
|
||||
private String bizName;
|
||||
private String nameEn;
|
||||
private String showType;
|
||||
private Boolean authorized = true;
|
||||
private String dataFormatType;
|
||||
@@ -22,6 +23,7 @@ public class QueryColumn {
|
||||
public QueryColumn(String bizName, String type) {
|
||||
this.type = type;
|
||||
this.bizName = bizName;
|
||||
this.nameEn = bizName;
|
||||
this.name = bizName;
|
||||
}
|
||||
|
||||
@@ -29,10 +31,16 @@ public class QueryColumn {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.bizName = bizName;
|
||||
this.nameEn = bizName;
|
||||
this.showType = "CATEGORY";
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type == null ? null : type;
|
||||
}
|
||||
|
||||
public void setBizName(String bizName) {
|
||||
this.bizName = bizName;
|
||||
this.nameEn = bizName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class BaseSemanticCorrector implements SemanticCorrector {
|
||||
try {
|
||||
String s2SQL = semanticParseInfo.getSqlInfo().getCorrectedS2SQL();
|
||||
if (Objects.isNull(s2SQL)) {
|
||||
return;
|
||||
semanticParseInfo.getSqlInfo().setCorrectedS2SQL(semanticParseInfo.getSqlInfo().getParsedS2SQL());
|
||||
}
|
||||
doCorrect(chatQueryContext, semanticParseInfo);
|
||||
log.debug("sqlCorrection:{} sql:{}", this.getClass().getSimpleName(),
|
||||
|
||||
@@ -178,7 +178,7 @@ export type QueryDataType = {
|
||||
export type ColumnType = {
|
||||
authorized: boolean;
|
||||
name: string;
|
||||
nameEn: string;
|
||||
bizName: string;
|
||||
showType: string;
|
||||
type: string;
|
||||
dataFormatType: string;
|
||||
|
||||
@@ -44,9 +44,9 @@ const BarChart: React.FC<Props> = ({
|
||||
const { queryColumns, queryResults, entityInfo } = data;
|
||||
|
||||
const categoryColumnName =
|
||||
queryColumns?.find(column => column.showType === 'CATEGORY')?.nameEn || '';
|
||||
queryColumns?.find(column => column.showType === 'CATEGORY')?.bizName || '';
|
||||
const metricColumn = queryColumns?.find(column => column.showType === 'NUMBER');
|
||||
const metricColumnName = metricColumn?.nameEn || '';
|
||||
const metricColumnName = metricColumn?.bizName || '';
|
||||
|
||||
const renderChart = () => {
|
||||
let instanceObj: any;
|
||||
@@ -158,7 +158,7 @@ const BarChart: React.FC<Props> = ({
|
||||
},
|
||||
},
|
||||
data: data.map(item => {
|
||||
return item[metricColumn?.nameEn || ''];
|
||||
return item[metricColumn?.bizName || ''];
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ const MetricCard: React.FC<Props> = ({ data, question, loading, onApplyAuth }) =
|
||||
const { metricInfos } = aggregateInfo || {};
|
||||
|
||||
const indicatorColumn = queryColumns?.find(column => column.showType === 'NUMBER');
|
||||
const indicatorColumnName = indicatorColumn?.nameEn || '';
|
||||
const indicatorColumnName = indicatorColumn?.bizName || '';
|
||||
|
||||
const { dataFormatType, dataFormat } = indicatorColumn || {};
|
||||
const value = queryResults?.[0]?.[indicatorColumnName] || 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ const MetricTrendChart: React.FC<Props> = ({
|
||||
instanceObj.clear();
|
||||
}
|
||||
|
||||
const valueColumnName = metricField.nameEn;
|
||||
const valueColumnName = metricField.bizName;
|
||||
const dataSource = resultList.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
|
||||
@@ -121,7 +121,7 @@ const MultiMetricsTrendChart: React.FC<Props> = ({
|
||||
showSymbol: resultList.length === 1,
|
||||
smooth: true,
|
||||
data: resultList.map((item: any) => {
|
||||
const value = item[metricField.nameEn];
|
||||
const value = item[metricField.bizName];
|
||||
return (metricField.dataFormatType === 'percent' ||
|
||||
metricField.dataFormatType === 'decimal') &&
|
||||
metricField.dataFormat?.needMultiply100
|
||||
|
||||
@@ -51,9 +51,9 @@ const MetricTrend: React.FC<Props> = ({
|
||||
const dateField: any = queryColumns?.find(
|
||||
(column: any) => column.showType === 'DATE' || column.type === 'DATE'
|
||||
);
|
||||
const dateColumnName = dateField?.nameEn || '';
|
||||
const dateColumnName = dateField?.bizName || '';
|
||||
const categoryColumnName =
|
||||
queryColumns?.find((column: any) => column.showType === 'CATEGORY')?.nameEn || '';
|
||||
queryColumns?.find((column: any) => column.showType === 'CATEGORY')?.bizName || '';
|
||||
const metricFields = queryColumns?.filter((column: any) => column.showType === 'NUMBER');
|
||||
|
||||
const currentMetricField = queryColumns?.find((column: any) => column.showType === 'NUMBER');
|
||||
|
||||
@@ -19,16 +19,16 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
||||
|
||||
const prefixCls = `${CLS_PREFIX}-table`;
|
||||
const tableColumns: any[] = queryColumns.map(
|
||||
({ name, nameEn, showType, dataFormatType, dataFormat, authorized }) => {
|
||||
({ name, bizName, showType, dataFormatType, dataFormat, authorized }) => {
|
||||
return {
|
||||
dataIndex: nameEn,
|
||||
key: nameEn,
|
||||
title: name || nameEn,
|
||||
dataIndex: bizName,
|
||||
key: bizName,
|
||||
title: name || bizName,
|
||||
defaultSortOrder: 'descend',
|
||||
sorter:
|
||||
showType === 'NUMBER'
|
||||
? (a, b) => {
|
||||
return a[nameEn] - b[nameEn];
|
||||
return a[bizName] - b[bizName];
|
||||
}
|
||||
: undefined,
|
||||
render: (value: string | number) => {
|
||||
@@ -59,7 +59,7 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (nameEn.includes('photo')) {
|
||||
if (bizName.includes('photo')) {
|
||||
return (
|
||||
<div className={`${prefixCls}-photo`}>
|
||||
<img width={40} height={40} src={value as string} alt="" />
|
||||
@@ -78,7 +78,7 @@ const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth })
|
||||
|
||||
const dateColumn = queryColumns.find(column => column.type === 'DATE');
|
||||
const dataSource = dateColumn
|
||||
? queryResults.sort((a, b) => moment(a[dateColumn.nameEn]).diff(moment(b[dateColumn.nameEn])))
|
||||
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
||||
: queryResults;
|
||||
return (
|
||||
<div className={prefixCls}>
|
||||
|
||||
@@ -17,10 +17,10 @@ const Text: React.FC<Props> = ({ columns, referenceColumn, dataSource }) => {
|
||||
const prefixCls = `${CLS_PREFIX}-text`;
|
||||
|
||||
const initData = () => {
|
||||
let textValue = dataSource[0][columns[0].nameEn];
|
||||
let textValue = dataSource[0][columns[0].bizName];
|
||||
setText(textValue === undefined ? '暂无数据' : textValue);
|
||||
if (referenceColumn) {
|
||||
const referenceDataValue = dataSource[0][referenceColumn.nameEn];
|
||||
const referenceDataValue = dataSource[0][referenceColumn.bizName];
|
||||
setReferenceData(referenceDataValue || []);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ const ChatMsg: React.FC<Props> = ({
|
||||
metricFields.length > 0 &&
|
||||
categoryField.length <= 1 &&
|
||||
!(metricFields.length > 1 && categoryField.length > 0) &&
|
||||
!dataSource.every(item => item[dateField.nameEn] === dataSource[0][dateField.nameEn]);
|
||||
!dataSource.every(item => item[dateField.bizName] === dataSource[0][dateField.bizName]);
|
||||
|
||||
if (isMetricTrend) {
|
||||
return MsgContentTypeEnum.METRIC_TREND;
|
||||
@@ -330,7 +330,7 @@ const ChatMsg: React.FC<Props> = ({
|
||||
!isEntityMode;
|
||||
|
||||
const recommendMetrics = chatContext?.metrics?.filter(metric =>
|
||||
queryColumns.every(queryColumn => queryColumn.nameEn !== metric.bizName)
|
||||
queryColumns.every(queryColumn => queryColumn.bizName !== metric.bizName)
|
||||
);
|
||||
|
||||
const isMultipleMetric =
|
||||
|
||||
Reference in New Issue
Block a user