mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-18 16:27:13 +00:00
[improvement][headless] Fix the issue of retrieving empty table information in H2 (#1789)
This commit is contained in:
@@ -45,8 +45,8 @@ public abstract class BaseDbAdaptor implements DbAdaptor {
|
|||||||
List<String> tablesAndViews = new ArrayList<>();
|
List<String> tablesAndViews = new ArrayList<>();
|
||||||
DatabaseMetaData metaData = getDatabaseMetaData(connectionInfo);
|
DatabaseMetaData metaData = getDatabaseMetaData(connectionInfo);
|
||||||
|
|
||||||
try (ResultSet resultSet =
|
try {
|
||||||
metaData.getTables(schemaName, schemaName, null, new String[] {"TABLE", "VIEW"})) {
|
ResultSet resultSet = getResultSet(schemaName, metaData);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
String name = resultSet.getString("TABLE_NAME");
|
String name = resultSet.getString("TABLE_NAME");
|
||||||
tablesAndViews.add(name);
|
tablesAndViews.add(name);
|
||||||
@@ -57,6 +57,11 @@ public abstract class BaseDbAdaptor implements DbAdaptor {
|
|||||||
return tablesAndViews;
|
return tablesAndViews;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ResultSet getResultSet(String schemaName, DatabaseMetaData metaData)
|
||||||
|
throws SQLException {
|
||||||
|
return metaData.getTables(schemaName, schemaName, null, new String[] {"TABLE", "VIEW"});
|
||||||
|
}
|
||||||
|
|
||||||
public List<DBColumn> getColumns(ConnectInfo connectInfo, String schemaName, String tableName)
|
public List<DBColumn> getColumns(ConnectInfo connectInfo, String schemaName, String tableName)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
List<DBColumn> dbColumns = Lists.newArrayList();
|
List<DBColumn> dbColumns = Lists.newArrayList();
|
||||||
|
|||||||
@@ -2,7 +2,13 @@ package com.tencent.supersonic.headless.core.adaptor.db;
|
|||||||
|
|
||||||
import com.tencent.supersonic.common.pojo.Constants;
|
import com.tencent.supersonic.common.pojo.Constants;
|
||||||
import com.tencent.supersonic.common.pojo.enums.TimeDimensionEnum;
|
import com.tencent.supersonic.common.pojo.enums.TimeDimensionEnum;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class H2Adaptor extends BaseDbAdaptor {
|
public class H2Adaptor extends BaseDbAdaptor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -30,6 +36,11 @@ public class H2Adaptor extends BaseDbAdaptor {
|
|||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ResultSet getResultSet(String schemaName, DatabaseMetaData metaData)
|
||||||
|
throws SQLException {
|
||||||
|
return metaData.getTables(schemaName, null, null, new String[] {"TABLE", "VIEW"});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String functionNameCorrector(String sql) {
|
public String functionNameCorrector(String sql) {
|
||||||
return sql;
|
return sql;
|
||||||
|
|||||||
Reference in New Issue
Block a user