Skip to content

[branch-1.4][Client] Add includeHistoricalProtocol param on getCDFFiles and streaming getFiles - #971

Merged
littlegrasscao merged 1 commit into
branch-1.4from
sucao/backport-969-1.4
Jun 29, 2026
Merged

littlegrasscao merged 1 commit into
branch-1.4from
sucao/backport-969-1.4

Conversation

@littlegrasscao

Copy link
Copy Markdown
Collaborator

Summary

Backport of #969 to branch-1.4 (clean cherry-pick of squash merge 8d323fb; one auto-merge hunk in DeltaSharingRestClientSuite, no manual conflict resolution required).

Client-side half of includeHistoricalProtocol support for both delta-sharing endpoints that can stream a range of versions:

  • getCDFFiles (GET .../changes) — flag is appended to the URL query string via getEncodedCDFParams, next to includeHistoricalMetadata.
  • streaming getFiles(table, startingVersion, endingVersion, fileIdHash) (POST .../query) — flag is set on the QueryTableRequest POST body (it logically belongs alongside startingVersion / endingVersion).

Both paths get a new includeHistoricalProtocol: Boolean = false parameter on the DeltaSharingClient trait. The TestDeltaSharingClient mock implementing the trait is updated to match. Server-side wiring lands in #970 (also targeted for backports).

Parquet-format gating

For parquet-only clients the flag is a no-op on the server — the parquet response returns the same single Protocol regardless. The client suppresses the flag (URL on /changes, body field on /query) for parquet-only clients to keep parquet-format requests byte-identical to today's. Clients negotiated for parquet,delta still forward the flag.

Backwards compatibility

  • Default is false, so existing call sites (RemoteDeltaCDFRelation, DeltaSharingSource, RemoteDeltaLogSuite, etc.) compile and behave unchanged.
  • When the flag is false, both the URL and the POST body are byte-for-byte identical to today's request, so old servers see no difference.
  • When the flag is true against an old server, the unknown URL query string parameter (on /changes) and the unknown body field (on /query) are simply ignored.

Test plan

  • client/Test/compile succeeds; scalastyle clean.
  • testOnly io.delta.sharing.client.DeltaSharingRestClientSuite -- -z "includeHistoricalProtocol" → 7 succeeded locally on branch-1.4.
  • Full CI on this PR.

Original PR

#969 (merged into main as 8d323fb).

â€Ķming getFiles (#969)

* [Client] Add includeHistoricalProtocol param on getCDFFiles

Add a new `includeHistoricalProtocol: Boolean = false` parameter on
`DeltaSharingClient.getCDFFiles`. When set, the REST client appends
`includeHistoricalProtocol=true` to the `/changes` URL alongside any
existing `includeHistoricalMetadata=true`, mirroring the existing
historical-metadata wire encoding.

This is the client-side half of the
`includeHistoricalProtocol` change. The matching server change (parse
the new query param and emit historical Protocol actions in
delta-format CDF responses) lands separately; this PR is wire-only and
fully backwards compatible:

- The new parameter defaults to `false`, so existing callers
  (RemoteDeltaCDFRelation, DeltaSharingSource, RemoteDeltaLogSuite,
  etc.) compile and behave unchanged.
- When `false`, the URL byte-for-byte matches today's request, so old
  servers see no difference.
- When `true` against an old server, the unknown query param is simply
  ignored.

Also updates `TestDeltaSharingClient` (a spark-test mock implementing
the trait) to match the new signature so the `spark` module still
compiles.

Two unit tests assert that the URL the REST client builds contains
`includeHistoricalProtocol=true` only when explicitly requested, and is
absent (while `includeHistoricalMetadata=true` is preserved) when not.

* [Client] Also support includeHistoricalProtocol on streaming getFiles

Extend the previous client change to the streaming `/query` path
(`getFiles(table, startingVersion, endingVersion, fileIdHash)`), so the
same `includeHistoricalProtocol` knob is available for both the CDF
endpoint and the streaming version-range endpoint.

Wire surface
- `QueryTableRequest` gains an `includeHistoricalProtocol: Option[Boolean]`
  field. `JsonUtils.mapper` already uses `Include.NON_ABSENT`, so when
  the client doesn't set it the JSON body is byte-identical to today's,
  and `FAIL_ON_UNKNOWN_PROPERTIES = false` on the server side means an
  older server simply ignores it.
- The streaming `getFiles` overload now takes an
  `includeHistoricalProtocol: Boolean = false` parameter (with a
  default so existing callers like `DeltaSharingSource` compile and
  behave unchanged), and populates the new request field only when
  true.

Tests
- Two new unit tests assert the streaming POST body contains
  `"includeHistoricalProtocol":true` only when explicitly requested,
  and is absent (no field at all) by default.

* [Client] Move streaming getFiles includeHistoricalProtocol to URL param

Switch the streaming `getFiles(startingVersion, ...)` overload's
`includeHistoricalProtocol` flag off the `QueryTableRequest` POST body
and onto a URL query string parameter, mirroring how
`getEncodedCDFParams` already encodes it on the `/changes` endpoint.

Wire surface
- `QueryTableRequest` case class: drop the `includeHistoricalProtocol:
  Option[Boolean]` field added in the previous commit.
- Streaming `getFiles`: when `includeHistoricalProtocol = true`, append
  `?includeHistoricalProtocol=true` to the `/query` target URL.
  Otherwise the target URL is byte-for-byte identical to today's, and
  the POSTed `QueryTableRequest` body is byte-for-byte identical to
  today's.

Public trait surface is unchanged from the previous commit: the
`includeHistoricalProtocol: Boolean = false` parameter on the streaming
`getFiles` overload (and its `TestDeltaSharingClient` override) stays
the same.

Tests
- The streaming unit tests now capture the target URL passed to
  `getNDJsonPost` (instead of the serialized request body) and assert:
  - When `includeHistoricalProtocol = true` is requested, the URL
    contains `includeHistoricalProtocol=true` AND the body does not
    mention `includeHistoricalProtocol`.
  - When not requested, neither the URL nor the body mentions
    `includeHistoricalProtocol`.
- All 4 unit tests (2 for `getCDFFiles` on `/changes`, 2 for streaming
  `getFiles` on `/query`) pass locally.

Backwards compatibility
- Default-`false` callers send a byte-identical request to today's
  servers (no URL query param, no body field).
- Old servers that don't understand `includeHistoricalProtocol` simply
  ignore the unknown query string parameter.

* [Client] Only forward includeHistoricalProtocol when responseFormat includes delta

`includeHistoricalProtocol` only has a meaningful representation in the
delta-format response (parquet-format responses don't carry inlined
Protocol actions). Suppress the URL param on both `getCDFFiles` and the
streaming `getFiles` overload whenever the client is configured for a
responseFormat that doesn't include `delta`, even if the caller passes
`includeHistoricalProtocol = true`. This keeps parquet-only requests
identical to before and avoids sending a flag the server would have to
ignore.

Adds three tests:
  - getCDFFiles: parquet-only client suppresses the flag.
  - getFiles(startingVersion, ...): parquet-only client suppresses the flag.
  - getCDFFiles: parquet+delta client still forwards the flag (server
    will pick delta-format response and inline historical Protocols).

* [Client] Clarify includeHistoricalProtocol gating rationale in comments

Reword the inline comments at both gating call sites (and the matching
test comment) to accurately describe why the flag is suppressed for
parquet-format clients: parquet responses return the same single
Protocol regardless of the flag, so it's a no-op on the server. No
behavior change.

* [Client] Move streaming getFiles includeHistoricalProtocol back to request body

The CDF helper `getEncodedCDFParams` continues to encode the flag as a
URL query string parameter on `/changes`. The streaming
`getFiles(startingVersion, ...)` overload moves the flag off the URL
and back onto the `QueryTableRequest` POST body, alongside
`startingVersion`/`endingVersion` and the other body-level parameters
it logically belongs to.

Wire surface
- `QueryTableRequest` case class: re-add
  `includeHistoricalProtocol: Option[Boolean] = None`.
- Streaming `getFiles`: drop the URL query-string append; set the body
  field to `Some(true)` only when the caller asked for it AND the
  client is configured to accept delta responses. Parquet-only callers
  send a byte-identical POST body and target URL to today's.

Tests
- The two streaming `getFiles` unit tests now assert on the captured
  request body JSON (`"includeHistoricalProtocol":true`) instead of
  the URL.
- The parquet-suppression streaming test asserts the body does not
  mention the flag for a parquet-only client.
- The 4 CDF-side tests are unchanged: CDF keeps the flag as a URL
  query string parameter.

All 7 `includeHistoricalProtocol` unit tests pass locally.

---------

Co-authored-by: Sun Cao <sun.cao+data@databricks.com>
@littlegrasscao
littlegrasscao force-pushed the sucao/backport-969-1.4 branch from 47e86e1 to 8667947 Compare June 29, 2026 18:23
@littlegrasscao
littlegrasscao merged commit 47f6382 into branch-1.4 Jun 29, 2026
5 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