Skip to content

Commit

Permalink
[Improve][Jdbc] Remove oracle 'v$database' query (#8571)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailin0 authored Jan 23, 2025
1 parent c4cb1fc commit 3cf09f6
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.seatunnel.api.table.catalog.Column;
import org.apache.seatunnel.api.table.catalog.ConstraintKey;
import org.apache.seatunnel.api.table.catalog.TablePath;
import org.apache.seatunnel.api.table.catalog.exception.CatalogException;
import org.apache.seatunnel.api.table.converter.BasicTypeDefine;
import org.apache.seatunnel.common.utils.JdbcUrlUtil;
import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.AbstractJdbcCatalog;
Expand All @@ -36,6 +37,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Slf4j
Expand Down Expand Up @@ -100,11 +102,6 @@ public OracleCatalog(
this.decimalTypeNarrowing = decimalTypeNarrowing;
}

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where name = '%s'", databaseName);
}

@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return getListTableSql(tablePath.getDatabaseName())
Expand All @@ -116,8 +113,13 @@ protected String getTableWithConditionSql(TablePath tablePath) {
}

@Override
protected String getListDatabaseSql() {
return "SELECT name FROM v$database";
public boolean databaseExists(String databaseName) throws CatalogException {
return true;
}

@Override
public List<String> listDatabases() throws CatalogException {
return new ArrayList<>(Collections.singletonList("default"));
}

@Override
Expand Down Expand Up @@ -195,11 +197,6 @@ protected String getOptionTableName(TablePath tablePath) {
return tablePath.getSchemaAndTableName();
}

private List<String> listTables() {
List<String> databases = listDatabases();
return listTables(databases.get(0));
}

@Override
public CatalogTable getTable(String sqlQuery) throws SQLException {
Connection defaultConnection = getConnection(defaultUrl);
Expand Down

0 comments on commit 3cf09f6

Please sign in to comment.