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