Skip to content

[core][rest] Push Format Table partition filters to REST catalog - #8785

Merged
JingsongLi merged 4 commits into
apache:masterfrom
sundapeng:format-table-partition-filter-rest-api
Jul 22, 2026
Merged

[core][rest] Push Format Table partition filters to REST catalog#8785
JingsongLi merged 4 commits into
apache:masterfrom
sundapeng:format-table-partition-filter-rest-api

Conversation

@sundapeng

@sundapeng sundapeng commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Push partition predicates for catalog-managed Format Tables to a REST partition-listing endpoint. This lets range, non-leading equality, IN, and other partition filters reduce catalog results while FormatTableScan keeps exact local filtering.

Follow-up to #8750.

Changes

  • Add POST .../partitions/list-by-filter, reusing ListPartitionsResponse.
  • Send the complete Paimon Predicate JSON together with the existing leading partition-name prefix; no separate filter grammar or translation layer is introduced.
  • Define filtered listing as best effort: unsupported predicates may return a superset, and the scan still applies the complete predicate locally.
  • Continue pagination until nextPageToken is empty, including sparse or empty pages, and fail fast on repeated tokens.
  • Fall back to the existing plain partition listing when filtered listing is unsupported, using the same Catalog instance for the operation.
  • Keep existing REST partition endpoints and non-managed Format Table behavior unchanged.

Testing

  • RESTCatalogTest: predicate transport, prefix conjunction, pagination, and superset behavior.
  • CatalogFormatTablePartitionManagerTest: filtered pagination, sparse pages, repeated-token detection, prefix enforcement, fallback, and Catalog lifecycle.
  • CatalogManagedPartitionScanTest: catalog-managed partition visibility and final local filtering.
  • ManagedFormatTablePartitionPruningTest: Spark SQL predicates reach the REST endpoint end to end.
  • GitHub Actions: all build and test checks pass.

Notes

  • The predicate is a pruning hint, not an authorization filter.
  • This PR reuses the existing Paimon Predicate JSON serde and does not change its schema.

@JingsongLi

Copy link
Copy Markdown
Contributor

Why not using Paimon Predicate? cc @plusplusjiajia

@sundapeng
sundapeng force-pushed the format-table-partition-filter-rest-api branch 2 times, most recently from ccd3184 to 3feccd2 Compare July 21, 2026 17:20
@sundapeng sundapeng changed the title [WIP][rest] Introduce partitions list-by-filter api definition [WIP][core][rest] Push partition filters to the REST catalog for Format Table scans Jul 21, 2026
@sundapeng
sundapeng force-pushed the format-table-partition-filter-rest-api branch 2 times, most recently from ba1a312 to 059f464 Compare July 21, 2026 18:04
@sundapeng sundapeng changed the title [WIP][core][rest] Push partition filters to the REST catalog for Format Table scans [WIP][core][common][rest] Push partition filters to the REST catalog for Format Table scans Jul 21, 2026
@sundapeng
sundapeng force-pushed the format-table-partition-filter-rest-api branch 5 times, most recently from 9999866 to 7974e93 Compare July 21, 2026 19:26
@sundapeng sundapeng changed the title [WIP][core][common][rest] Push partition filters to the REST catalog for Format Table scans [WIP][core][rest] Push partition filters to the REST catalog for Format Table scans Jul 21, 2026
The request carries the partition predicate in its filter field as the
JSON serialization of a Paimon Predicate tree. The server evaluates it
in a best-effort way: a tree it cannot restore or re-anchor counts as
always-true, so the response is a superset of the matching partitions
and never misses one, and callers keep applying the predicate on the
returned partitions. Pages may be sparse; only an empty nextPageToken
ends the listing. The mock server records received filter requests so
tests can assert the transport path.
Send the partition predicate of a managed Format Table scan to the
partitions/list-by-filter endpoint together with the existing name
prefix. The predicate travels as its own flat JSON serialization, so
the server evaluates exactly the tree the scan evaluates locally and
there is no translation step; the scan keeps no pushdown policy of its
own — whatever partition predicate exists goes to the manager.
Request sizing is left to the HTTP layer, and the server weakens what
it cannot evaluate instead of rejecting it, returning a superset
(today that includes temporal and decimal literals, whose JSON round
trip stays unrestorable until the literal serde is hardened upstream).
Falling back is stateless and stays inside the one catalog the
operation loaded: a catalog without the endpoint (an
UnsupportedOperationException, into which the REST catalog translates
HTTP 501, or the endpoint 404) costs one rejected probe per filtered
scan and the same call retries the plain prefix listing, so behavior
is identical across copies, serialization and processes. The
per-partition filter in the plan is unchanged, and a Spark suite pins
the chain end to end: a Spark SQL partition predicate must reach the
filtered listing endpoint and restore to the pushed tree.
@sundapeng
sundapeng force-pushed the format-table-partition-filter-rest-api branch from 7974e93 to 9b577f5 Compare July 21, 2026 19:37
@sundapeng sundapeng changed the title [WIP][core][rest] Push partition filters to the REST catalog for Format Table scans [core][rest] Push partition filters to the REST catalog for Format Table scans Jul 22, 2026
@sundapeng sundapeng changed the title [core][rest] Push partition filters to the REST catalog for Format Table scans [core][rest] Push Format Table partition filters to REST catalog Jul 22, 2026
@sundapeng
sundapeng marked this pull request as ready for review July 22, 2026 01:10
pageToken,
pattern));
} catch (Exception e) {
if (!indicatesNoFilterListing(e)) {

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.

Do not catch this, must support list by filter.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@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.

Please update rest-catalog-open-api.yaml

@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit b52f55f into apache:master Jul 22, 2026
14 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