Skip to content

DuckDBJ: DuckDBDatabaseMetaData.getTables always throws when specifying a catalog argument, whereas DuckDBDatabaseMetaData.getColumns doesn't #6227

@rpbouman

Description

@rpbouman

What happens?

java.sql.DatabaseMetadata.getTables() supports a catalog argument (https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/DatabaseMetaData.html#getTables(java.lang.String,java.lang.String,java.lang.String,java.lang.String%5B%5D)). However, the implementation in org.duckdb.DuckDBDatabaseMetaData (https://github.com/duckdb/duckdb/blob/master/tools/jdbc/src/main/java/org/duckdb/DuckDBDatabaseMetaData.java#L676) always throws when it is not null or empty:

		if (catalog != null && !catalog.isEmpty()) {
			throw new SQLException("Actual catalog argument is not supported, got " + catalog);
		}        

It could be that duckdb simply chooses not to support this, but then it is strange (inconsistent) that a method like org.duckdb.DuckDBDatabaseMetaData.getColumns handles the catalog argument just like any other argument (i.e. it just uses it to filter and does not throw when not empty or null)

(BTW there is another issue with getColumns which is related but still different #6225)

To Reproduce

public static void test_get_tables_with_catalog() throws Exception {
	Connection conn = DriverManager.getConnection("jdbc:duckdb:");
	String catalog = conn.getCatalog();
	DatabaseMetaData databaseMetaData = conn.getMetaData();
	try {
		databaseMetaData.getTables(catalog, null, "%", null);
	}
	catch (SQLException ex) {
		assertFalse(ex.getMessage().startsWith("Actual catalog argument is not supported"));
	}
}

OS:

Windows 10 Pro

DuckDB Version:

v0.6.2-dev2342

DuckDB Client:

DuckDBJ

Full Name:

Roland Bouman

Affiliation:

Just-Bi.nl (an EPAM company)

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions