Skip to content

Commit

Permalink
Use new Schemata information table for getCatalogs(), getSchemas() (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnsmith authored and rflprr committed Jul 31, 2017
1 parent 95a063d commit ddc05c7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ public String getCatalogTerm() {
return CATALOG_TERM;
}

@Override
public ResultSet getCatalogs() throws SQLException {
Object[][] rows = {{catalog}};
return MetaDataSchema.newResultSet(MetaDataSchema.CATALOG_COLUMNS, rows);
}

@Override
public ResultSet getClientInfoProperties() throws SQLException {
return MetaDataSchema.newResultSet(MetaDataSchema.CLIENT_INFO_PROPERTY_COLUMNS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public SparqlDatabaseMetaData(DataWorldConnection connection, String catalog, St
super(connection, catalog, schema);
}

@Override
public ResultSet getCatalogs() throws SQLException {
Object[][] rows = {{catalog}};
return MetaDataSchema.newResultSet(MetaDataSchema.CATALOG_COLUMNS, rows);
}

@Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
return MetaDataSchema.newResultSet(MetaDataSchema.COLUMN_COLUMNS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ public SqlDatabaseMetaData(DataWorldConnection connection, String catalog, Strin
super(connection, catalog, schema);
}

@Override
public ResultSet getCatalogs() throws SQLException {
List<Object[]> rows = new ArrayList<>();
try (PreparedStatement statement = connection.prepareStatement(
"SELECT DISTINCT owner" +
" FROM Schemata" +
" ORDER BY owner")) {
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
String owner = resultSet.getString("owner");
rows.add(new Object[]{
// TABLE_CAT String => catalog name
owner,
});
}
}
return MetaDataSchema.newResultSet(MetaDataSchema.CATALOG_COLUMNS, rows);
}

@Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
List<Object[]> rows = new ArrayList<>();
Expand Down Expand Up @@ -165,7 +184,7 @@ public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLExce
List<Object[]> rows = new ArrayList<>();
try (PreparedStatement statement = connection.prepareStatement(
"SELECT DISTINCT owner, dataset" +
" FROM Tables" +
" FROM Schemata" +
" WHERE owner = COALESCE(?,owner)" +
" AND dataset LIKE ?" +
" ORDER BY owner, dataset")) {
Expand Down

0 comments on commit ddc05c7

Please sign in to comment.