Skip to content

Conversation

@pan3793
Copy link
Member

@pan3793 pan3793 commented Oct 31, 2025

What changes were proposed in this pull request?

Implement getSchemas methods defined in java.sql.DatabaseMetaData for SparkConnectDatabaseMetaData.

    /**
     * Retrieves the schema names available in this database.  The results
     * are ordered by {@code TABLE_CATALOG} and
     * {@code TABLE_SCHEM}.
     *
     * <P>The schema columns are:
     *  <OL>
     *  <LI><B>TABLE_SCHEM</B> String {@code =>} schema name
     *  <LI><B>TABLE_CATALOG</B> String {@code =>} catalog name (may be {@code null})
     *  </OL>
     *
     * @return a {@code ResultSet} object in which each row is a
     *         schema description
     * @throws SQLException if a database access error occurs
     *
     */
    ResultSet getSchemas() throws SQLException;

    /**
     * Retrieves the schema names available in this database.  The results
     * are ordered by {@code TABLE_CATALOG} and
     * {@code TABLE_SCHEM}.
     *
     * <P>The schema columns are:
     *  <OL>
     *  <LI><B>TABLE_SCHEM</B> String {@code =>} schema name
     *  <LI><B>TABLE_CATALOG</B> String {@code =>} catalog name (may be {@code null})
     *  </OL>
     *
     *
     * @param catalog a catalog name; must match the catalog name as it is stored
     * in the database;"" retrieves those without a catalog; null means catalog
     * name should not be used to narrow down the search.
     * @param schemaPattern a schema name; must match the schema name as it is
     * stored in the database; null means
     * schema name should not be used to narrow down the search.
     * @return a {@code ResultSet} object in which each row is a
     *         schema description
     * @throws SQLException if a database access error occurs
     * @see #getSearchStringEscape
     * @since 1.6
     */
    ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException;

Why are the changes needed?

Enhance API coverage of the Connect JDBC driver, for example, get[Catalogs|Schemas|Tables|...] APIs are used by SQL GUI tools such as DBeaver for displaying the tree category.

Does this PR introduce any user-facing change?

No, Connect JDBC driver is a new feature under development.

How was this patch tested?

New UT is added, also tested via DBeaver - the catalog/schema tree works now.

Xnip2025-11-01_01-33-38

Was this patch authored or co-authored using generative AI tooling?

No.

override def dataDefinitionIgnoredInTransactions: Boolean = false

private def isNullOrWildcard(pattern: String): Boolean =
pattern == null || pattern == "%"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to test whether fooPattern matches ALL

https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/DatabaseMetaData.html

Some DatabaseMetaData methods take arguments that are String patterns. These arguments all have names such as fooPattern. Within a pattern String, "%" means match any substring of 0 or more characters, and "_" means match any one character. Only metadata entries matching the search pattern are returned. If a search pattern argument is set to null, that argument's criterion will be dropped from the search.

@pan3793 pan3793 marked this pull request as ready for review November 3, 2025 06:47
@pan3793
Copy link
Member Author

pan3793 commented Nov 3, 2025

this is ready for review, cc @LuciferYang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant