Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public List<Schema> schemas(Connection connection, String databaseName) {
@Override
public String tableDDL(Connection connection, @NotEmpty String databaseName, String schemaName,
@NotEmpty String tableName) {
String sql = "SHOW CREATE TABLE " + format(databaseName) + "."
// In Hive, schema and database are the same concept. Fall back to schemaName when databaseName is absent.
String effectiveDb = StringUtils.isNotBlank(databaseName) ? databaseName : schemaName;
String sql = "SHOW CREATE TABLE " + format(effectiveDb) + "."
+ format(tableName);
return SQLExecutor.getInstance().execute(connection, sql, resultSet -> {
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -97,7 +99,9 @@ public SqlBuilder getSqlBuilder() {
// TODO 待完善
@Override
public List<TableColumn> columns(Connection connection, String databaseName, String schemaName, String tableName) {
String sql = String.format(SELECT_TAB_COLS, databaseName, tableName);
// In Hive, schema and database are the same concept. Fall back to schemaName when databaseName is absent.
String effectiveDb = StringUtils.isNotBlank(databaseName) ? databaseName : schemaName;
String sql = String.format(SELECT_TAB_COLS, effectiveDb, tableName);
return SQLExecutor.getInstance().execute(connection, sql, resultSet -> {
List<TableColumn> tableColumns = new ArrayList<>();
Map<String, String> detailTableInfo = new HashMap<>();
Expand Down Expand Up @@ -268,7 +272,9 @@ public static String format(String name) {

@Override
public Table view(Connection connection, String databaseName, String schemaName, String viewName) {
String sql = String.format(VIEW_SQL, databaseName, viewName);
// In Hive, schema and database are the same concept. Fall back to schemaName when databaseName is absent.
String effectiveDb = StringUtils.isNotBlank(databaseName) ? databaseName : schemaName;
String sql = String.format(VIEW_SQL, effectiveDb, viewName);
return SQLExecutor.getInstance().execute(connection, sql, resultSet -> {
Table table = new Table();
table.setDatabaseName(databaseName);
Expand Down