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