Skip to content

Commit

Permalink
[improvement][headless] Fix the issue of retrieving empty table infor…
Browse files Browse the repository at this point in the history
…mation in H2 (#1789)
  • Loading branch information
lexluo09 authored Oct 12, 2024
1 parent 3501f59 commit fc94a67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public List<String> getTables(ConnectInfo connectionInfo, String schemaName)
List<String> tablesAndViews = new ArrayList<>();
DatabaseMetaData metaData = getDatabaseMetaData(connectionInfo);

try (ResultSet resultSet =
metaData.getTables(schemaName, schemaName, null, new String[] {"TABLE", "VIEW"})) {
try {
ResultSet resultSet = getResultSet(schemaName, metaData);
while (resultSet.next()) {
String name = resultSet.getString("TABLE_NAME");
tablesAndViews.add(name);
Expand All @@ -57,6 +57,11 @@ public List<String> getTables(ConnectInfo connectionInfo, String schemaName)
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)
throws SQLException {
List<DBColumn> dbColumns = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import com.tencent.supersonic.common.pojo.Constants;
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 {

@Override
Expand Down Expand Up @@ -30,6 +36,11 @@ public String getDateFormat(String dateType, String dateFormat, String column) {
return column;
}

protected ResultSet getResultSet(String schemaName, DatabaseMetaData metaData)
throws SQLException {
return metaData.getTables(schemaName, null, null, new String[] {"TABLE", "VIEW"});
}

@Override
public String functionNameCorrector(String sql) {
return sql;
Expand Down

0 comments on commit fc94a67

Please sign in to comment.