Skip to content

[jdbc] Implement real paging and pattern filtering for listViewsPaged.#8817

Merged
JingsongLi merged 1 commit into
apache:masterfrom
Stephen0421:jdbc-catalog-support-paged
Jul 23, 2026
Merged

[jdbc] Implement real paging and pattern filtering for listViewsPaged.#8817
JingsongLi merged 1 commit into
apache:masterfrom
Stephen0421:jdbc-catalog-support-paged

Conversation

@Stephen0421

Copy link
Copy Markdown
Contributor

Purpose

JdbcCatalog.listViewsPaged previously returned all views in a single page and ignored paging/pattern parameters. This PR implements the real behavior:

  • Cursor-based paging via an exclusive cursor (view_name > ?) ordered by view_name. The previous page's last name is returned as the opaque nextPageToken; the next request resumes strictly after it. LIMIT
    maxResults + 1 is fetched so the existence of a next page is detected without a separate count.
  • Pattern filtering pushed down to SQL LIKE (view_name LIKE ?).
  • maxResults == null or 0 means "no paging" — all matching views are returned with no next page; a negative value is rejected.
  • null or empty viewNamePattern means "no pattern" — all views are returned (per the Catalog contract, which says "if not set or empty").
  • System databases return an empty page; a non-existent database throws DatabaseNotExistException.
  • listViewDetailsPaged reuses the paged name list and resolves each view via getView, mirroring the existing listTableDetailsPagedImpl pattern in AbstractCatalog.

Design notes:

  • The view table's primary key is (catalog_key, view_database, view_name), so view_name is unique per database — the exclusive cursor is stable (no dropped/duplicated rows across pages).
  • CatalogUtils.validateNamePattern is intentionally not called here: this method supports LIKE directly. supportsListByPattern() remains false so that listTablesPaged/listDatabasesPaged (which still use the
    all-objects fallback) continue to throw UnsupportedOperationException on a pattern rather than silently returning unfiltered results. The Catalog javadoc for supportsListByPattern() is updated to document
    that a single method may honor a pattern by overriding it directly, independent of the flag.
  • The listViewsPaged/listViewDetailsPaged javadoc is relaxed: pattern semantics (full LIKE vs prefix-only) is now stated as catalog-specific, matching the real JdbcCatalog behavior.

Tests

Added testListViewsPaged and testListViewDetailsPaged to JdbcCatalogTest covering:

  • Empty database → empty page, no next token.
  • maxResults == null, 0, and larger than the full set → all views, no next page.
  • Empty pattern → all views.
  • Full paging walk with maxResults = 2 (next-page token is the last name of each page; final page has no token).
  • pageToken resumes strictly after the token value.
  • Negative maxResults → IllegalArgumentException.
  • DatabaseNotExistException for a missing database.
  • LIKE patterns: view%, view_, _bd, zzz% (empty result).
  • Pattern combined with paging.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@JingsongLi
JingsongLi merged commit ea1aa7c into apache:master Jul 23, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants