forked from github/dataease
fix: 修复低版本的ck获取表错误
This commit is contained in:
parent
0180110e93
commit
4b13d91741
@ -98,16 +98,19 @@ public class CalciteProvider extends Provider {
|
|||||||
@Override
|
@Override
|
||||||
public List<DatasetTableDTO> getTables(DatasourceRequest datasourceRequest) {
|
public List<DatasetTableDTO> getTables(DatasourceRequest datasourceRequest) {
|
||||||
List<DatasetTableDTO> tables = new ArrayList<>();
|
List<DatasetTableDTO> tables = new ArrayList<>();
|
||||||
|
|
||||||
|
try (ConnectionObj con = getConnection(datasourceRequest.getDatasource()); Statement statement = getStatement(con.getConnection(), 30)) {
|
||||||
|
datasourceRequest.setDsVersion(con.getConnection().getMetaData().getDatabaseMajorVersion());
|
||||||
List<String> tablesSqls = getTablesSql(datasourceRequest);
|
List<String> tablesSqls = getTablesSql(datasourceRequest);
|
||||||
for (String tablesSql : tablesSqls) {
|
for (String tablesSql : tablesSqls) {
|
||||||
try (ConnectionObj con = getConnection(datasourceRequest.getDatasource()); Statement statement = getStatement(con.getConnection(), 30); ResultSet resultSet = statement.executeQuery(tablesSql)) {
|
ResultSet resultSet = statement.executeQuery(tablesSql);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
tables.add(getTableDesc(datasourceRequest, resultSet));
|
tables.add(getTableDesc(datasourceRequest, resultSet));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DEException.throwException(e.getMessage());
|
DEException.throwException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return tables;
|
return tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +240,7 @@ public class CalciteProvider extends Provider {
|
|||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
try (ConnectionObj con = getConnection(datasourceRequest.getDatasource());
|
try (ConnectionObj con = getConnection(datasourceRequest.getDatasource());
|
||||||
Statement statement = getStatement(con.getConnection(), 30)) {
|
Statement statement = getStatement(con.getConnection(), 30)) {
|
||||||
|
datasourceRequest.setDsVersion(con.getConnection().getMetaData().getDatabaseMajorVersion());
|
||||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase("mongo") || datasourceRequest.getDatasource().getType().equalsIgnoreCase("doris")) {
|
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase("mongo") || datasourceRequest.getDatasource().getType().equalsIgnoreCase("doris")) {
|
||||||
resultSet = statement.executeQuery("select * from " + table + " limit 0 offset 0 ");
|
resultSet = statement.executeQuery("select * from " + table + " limit 0 offset 0 ");
|
||||||
return fetchResultField(resultSet);
|
return fetchResultField(resultSet);
|
||||||
@ -1054,7 +1058,12 @@ public class CalciteProvider extends Provider {
|
|||||||
String[] databasePrams = matcher.group(3).split("\\?");
|
String[] databasePrams = matcher.group(3).split("\\?");
|
||||||
database = databasePrams[0];
|
database = databasePrams[0];
|
||||||
}
|
}
|
||||||
|
if(datasourceRequest.getDsVersion() < 22){
|
||||||
|
tableSqls.add("SELECT name, name FROM system.tables where database='DATABASE';".replace("DATABASE", database));
|
||||||
|
}else {
|
||||||
tableSqls.add("SELECT name, comment FROM system.tables where database='DATABASE';".replace("DATABASE", database));
|
tableSqls.add("SELECT name, comment FROM system.tables where database='DATABASE';".replace("DATABASE", database));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -15,6 +15,7 @@ public class DatasourceRequest implements Serializable {
|
|||||||
protected String query;
|
protected String query;
|
||||||
protected String table;
|
protected String table;
|
||||||
protected DatasourceDTO datasource;
|
protected DatasourceDTO datasource;
|
||||||
|
private Integer dsVersion;
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
private Integer page;
|
private Integer page;
|
||||||
private Integer realSize;
|
private Integer realSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user