Merge branch 'v1.8' into dev

This commit is contained in:
taojinlong 2022-02-28 23:02:04 +08:00
commit b9bbbe1907
5 changed files with 40 additions and 10 deletions

View File

@ -99,11 +99,18 @@ public class EsProvider extends DatasourceProvider {
@Override
public List<TableField> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
datasourceRequest.setQuery(qp.convertTableToSql(datasourceRequest.getTable(), datasourceRequest.getDatasource()));
return fetchResultField(datasourceRequest);
datasourceRequest.setQuery("desc " + datasourceRequest.getTable());
List<TableField> tableFields = new ArrayList<>();
try {
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "?format=json");
tableFields = fetchResultField4Table(response);
} catch (Exception e) {
DataEaseException.throwException(e);
}
return tableFields;
}
private List<String[]> fetchResult(String response) throws Exception {
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
return fetchResult(esReponse);
@ -166,6 +173,26 @@ public class EsProvider extends DatasourceProvider {
return fieldList;
}
private List<TableField> fetchResultField4Table(String response) throws Exception {
List<TableField> fieldList = new ArrayList<>();
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
if (esReponse.getError() != null) {
throw new Exception(esReponse.getError().getReason());
}
for (String[] row : esReponse.getRows()) {
if(!row[1].equalsIgnoreCase("STRUCT")){
TableField field = new TableField();
field.setFieldName(row[0]);
field.setRemarks(row[0]);
field.setFieldType(row[2]);
field.setFieldSize(EsQueryProvider.transFieldTypeSize(row[2]));
fieldList.add(field);
}
}
return fieldList;
}
@Override
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
Map<String, List> result = new HashMap<>();

View File

@ -403,6 +403,9 @@ public class JdbcProvider extends DatasourceProvider {
}
private Connection getConnectionFromPool(DatasourceRequest datasourceRequest) throws Exception {
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mongo.name())){
return getConnection(datasourceRequest);
}
DruidDataSource dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId());
if (dataSource == null) {
handleDatasource(datasourceRequest, "add");

View File

@ -1629,7 +1629,7 @@ public class DataSetTableService {
datasetTableField.setDeExtractType(transFieldType(filed.getFieldType()));
} else {
Integer fieldType = qp.transFieldType(filed.getFieldType());
datasetTableField.setDeType(fieldType == 4 ? 2 : fieldType);
datasetTableField.setDeType(fieldType == 4 ? 2 : (fieldType == 6 ? 0 : fieldType));
datasetTableField.setDeExtractType(fieldType);
}
datasetTableField.setSize(filed.getFieldSize());
@ -1637,7 +1637,7 @@ public class DataSetTableService {
datasetTableField.setColumnIndex(i);
datasetTableField.setLastSyncTime(syncTime);
datasetTableField.setExtField(0);
datasetTableField.setGroupType(datasetTableField.getDeType() < 2 ? "d" : "q");
datasetTableField.setGroupType((datasetTableField.getDeType() < 2 || datasetTableField.getDeType() == 6) ? "d" : "q");
}
dataSetTableFieldsService.save(datasetTableField);
}

View File

@ -72,8 +72,8 @@
</el-option>
</el-select>
<span style="margin-left: 8px;">
<span v-if="scope.row.deType === 0">
<svg-icon v-if="scope.row.deType === 0" icon-class="field_text" class="field-icon-text" />
<span v-if="scope.row.deType === 0 || scope.row.deType === 6">
<svg-icon v-if="scope.row.deType === 0 || scope.row.deType === 6" icon-class="field_text" class="field-icon-text" />
<span class="field-class">{{ $t('dataset.text') }}</span>
</span>
<span v-if="scope.row.deType === 1">
@ -95,8 +95,8 @@
<el-table-column property="deExtractType" :label="$t('dataset.origin_field_type')" width="100">
<template slot-scope="scope">
<span v-if="scope.row.extField === 0">
<span v-if="scope.row.deExtractType === 0">
<svg-icon v-if="scope.row.deExtractType === 0" icon-class="field_text" class="field-icon-text" />
<span v-if="scope.row.deExtractType === 0 || scope.row.deExtractType === 6">
<svg-icon v-if="scope.row.deExtractType === 0 || scope.row.deExtractType === 6" icon-class="field_text" class="field-icon-text" />
<span class="field-class">{{ $t('dataset.text') }}</span>
</span>
<span v-if="scope.row.deExtractType === 1">

View File

@ -253,7 +253,7 @@
</el-select>
</el-form-item>
<el-collapse v-if="form.configuration.dataSourceType=='jdbc' && form.type !== 'api'">
<el-collapse v-if="form.configuration.dataSourceType=='jdbc' && form.type !== 'api' && form.type !== 'mongo'">
<el-collapse-item :title="$t('datasource.priority')" name="1">
<el-form-item :label="$t('datasource.initial_pool_size')" prop="configuration.initialPoolSize">
<el-input v-model="form.configuration.initialPoolSize" autocomplete="off" type="number" min="0"