Repository navigation
[branch-1.4][Client] Add includeHistoricalProtocol param on getCDFFiles and streaming getFiles - #971
Merged
Merged
Conversation
âĶ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
force-pushed
the
sucao/backport-969-1.4
branch
from
June 29, 2026 18:23
47e86e1 to
8667947
Compare
linzhou-db
approved these changes
Jun 29, 2026
linzhou-db
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of #969 to
branch-1.4(clean cherry-pick of squash merge8d323fb; one auto-merge hunk inDeltaSharingRestClientSuite, no manual conflict resolution required).Client-side half of
includeHistoricalProtocolsupport for both delta-sharing endpoints that can stream a range of versions:getCDFFiles(GET .../changes) â flag is appended to the URL query string viagetEncodedCDFParams, next toincludeHistoricalMetadata.getFiles(table, startingVersion, endingVersion, fileIdHash)(POST .../query) â flag is set on theQueryTableRequestPOST body (it logically belongs alongsidestartingVersion/endingVersion).Both paths get a new
includeHistoricalProtocol: Boolean = falseparameter on theDeltaSharingClienttrait. TheTestDeltaSharingClientmock 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 forparquet,deltastill forward the flag.Backwards compatibility
false, so existing call sites (RemoteDeltaCDFRelation,DeltaSharingSource,RemoteDeltaLogSuite, etc.) compile and behave unchanged.false, both the URL and the POST body are byte-for-byte identical to today's request, so old servers see no difference.trueagainst 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/compilesucceeds; scalastyle clean.testOnly io.delta.sharing.client.DeltaSharingRestClientSuite -- -z "includeHistoricalProtocol"â 7 succeeded locally onbranch-1.4.Original PR
#969 (merged into
mainas8d323fb).