Retention SET POLICY AT TIME ZONE (Spark 3.5 SQL surface) - #735
Open
mkuchenbecker wants to merge 7 commits into
Open
mkuchenbecker wants to merge 7 commits into
mkuchenbecker wants to merge 7 commits into
Conversation
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-dml
branch
from
September 17, 2026 16:57
1116db2 to
30a3116
Compare
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 17, 2026 17:00
1cabb2f to
a45ec05
Compare
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-dml
branch
from
September 17, 2026 21:25
30a3116 to
d79adb8
Compare
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 17, 2026 21:25
64c083b to
b1e31eb
Compare
mkuchenbecker
commented
Sep 17, 2026
mkuchenbecker
commented
Sep 17, 2026
mkuchenbecker
added a commit
that referenced
this pull request
Sep 17, 2026
…th a library - Rename the SQL clause from AT TIME ZONE to WITH TIMEZONE. - Reject an unresolvable time zone at the SET POLICY boundary with a clear error instead of silently persisting a policy the retention job cannot evaluate. - Build the retention policy JSON with a Jackson object writer, which escapes owner-supplied values, and drop the hand-written escaper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 17, 2026 23:44
b1e31eb to
11b2de5
Compare
mkuchenbecker
changed the base branch from
mkuchenbecker/retention-timezone-dml
to
mkuchenbecker/retention-timezone-support
September 17, 2026 23:44
mkuchenbecker
commented
Sep 18, 2026
| val mapper = new ObjectMapper() | ||
| val retention = mapper.createObjectNode() | ||
| retention.put("count", count) | ||
| retention.put("granularity", granularity) |
Collaborator
Author
There was a problem hiding this comment.
make this function pure. No local member access.
mkuchenbecker
commented
Sep 18, 2026
|
|
||
| /** | ||
| * Reject an invalid time zone at this boundary rather than persisting a policy the retention job | ||
| * cannot resolve. A table owner supplies the zone as free text in the SQL statement. |
Collaborator
Author
There was a problem hiding this comment.
document the unchecked exception in the signature. Explain why its unchecked ( run override doesn't have checked exceptions)
mkuchenbecker
commented
Sep 18, 2026
| @@ -0,0 +1,119 @@ | |||
| package com.linkedin.openhouse.spark.statementtest; | |||
Collaborator
Author
There was a problem hiding this comment.
you need a proper integration test setting and validating this through the api. Use actual Json parsing vs "contains" in this class.
14 tasks
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
…th a library - Rename the SQL clause from AT TIME ZONE to WITH TIMEZONE. - Reject an unresolvable time zone at the SET POLICY boundary with a clear error instead of silently persisting a policy the retention job cannot evaluate. - Build the retention policy JSON with a Jackson object writer, which escapes owner-supplied values, and drop the hand-written escaper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 18, 2026 18:30
11b2de5 to
984f01f
Compare
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
- Move retentionPolicyJson and validateTimeZone to the companion object as pure functions that read only their arguments, no instance-member access. - Document that validateTimeZone throws an unchecked IllegalArgumentException, and why it is unchecked: the inherited run override declares no checked exception, matching the unchecked rejection the sibling policy execs use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
…yped JSON Rewrite the retention time-zone test as an OpenHouseSparkITest that runs SET POLICY through the OpenHouse catalog against the embedded tables service, then reads the stored policy back and parses it into the typed Policies model to assert the zone round-trips, instead of asserting on a substring of the raw property. Covers an IANA zone, a fixed offset, the no-zone case, and rejection of an unresolvable zone. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
…th a library - Rename the SQL clause from AT TIME ZONE to WITH TIMEZONE. - Reject an unresolvable time zone at the SET POLICY boundary with a clear error instead of silently persisting a policy the retention job cannot evaluate. - Build the retention policy JSON with a Jackson object writer, which escapes owner-supplied values, and drop the hand-written escaper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
- Move retentionPolicyJson and validateTimeZone to the companion object as pure functions that read only their arguments, no instance-member access. - Document that validateTimeZone throws an unchecked IllegalArgumentException, and why it is unchecked: the inherited run override declares no checked exception, matching the unchecked rejection the sibling policy execs use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
…yped JSON Rewrite the retention time-zone test as an OpenHouseSparkITest that runs SET POLICY through the OpenHouse catalog against the embedded tables service, then reads the stored policy back and parses it into the typed Policies model to assert the zone round-trips, instead of asserting on a substring of the raw property. Covers an IANA zone, a fixed offset, the no-zone case, and rejection of an unresolvable zone. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 18, 2026 20:24
2d12ff9 to
7c5686b
Compare
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
…th a library - Rename the SQL clause from AT TIME ZONE to WITH TIMEZONE. - Reject an unresolvable time zone at the SET POLICY boundary with a clear error instead of silently persisting a policy the retention job cannot evaluate. - Build the retention policy JSON with a Jackson object writer, which escapes owner-supplied values, and drop the hand-written escaper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
- Move retentionPolicyJson and validateTimeZone to the companion object as pure functions that read only their arguments, no instance-member access. - Document that validateTimeZone throws an unchecked IllegalArgumentException, and why it is unchecked: the inherited run override declares no checked exception, matching the unchecked rejection the sibling policy execs use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
added a commit
that referenced
this pull request
Sep 18, 2026
…yped JSON Rewrite the retention time-zone test as an OpenHouseSparkITest that runs SET POLICY through the OpenHouse catalog against the embedded tables service, then reads the stored policy back and parses it into the typed Policies model to assert the zone round-trips, instead of asserting on a substring of the raw property. Covers an IANA zone, a fixed offset, the no-zone case, and rejection of an unresolvable zone. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 18, 2026 21:16
7c5686b to
a0e31bc
Compare
Extend the OpenHouse Spark 3.5 SQL extension so a table owner can configure the retention time zone from SQL: ALTER TABLE db.t SET POLICY (RETENTION=30D AT TIME ZONE 'America/Los_Angeles') The grammar gains an optional AT TIME ZONE STRING on the retention clause (AT, TIME, ZONE are non-reserved so they remain valid identifiers). The AST builder threads the zone through the SetRetentionPolicy plan and the exec serializes it into the retention policy JSON as "timeZone":"...". An absent clause omits the field, so existing statements are unchanged. Tests: SetRetentionTimeZoneStatementTest (spark-3.5 itest) asserts the stored policy JSON for an IANA zone, a fixed offset, a zone with a column pattern, and the no-zone case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Spark 3.5 SET POLICY execution built the retention policy JSON by interpolating the time zone, column name, and column pattern directly into the string. A value containing a double quote or backslash could break out of the JSON string and inject additional policy fields. Escape those free-text values per the JSON string grammar before embedding them, so a crafted value is stored as an inert literal that the server-side validators then accept or reject on its own merits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address pedantic review nits in the new statement test: replace the manual StringBuilder loop in the property accessor with a stream pipeline, declare the checked setup failure with throws Exception instead of hiding it behind @SneakyThrows, and drop the redundant null initializer on the session field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…th a library - Rename the SQL clause from AT TIME ZONE to WITH TIMEZONE. - Reject an unresolvable time zone at the SET POLICY boundary with a clear error instead of silently persisting a policy the retention job cannot evaluate. - Build the retention policy JSON with a Jackson object writer, which escapes owner-supplied values, and drop the hand-written escaper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move retentionPolicyJson and validateTimeZone to the companion object as pure functions that read only their arguments, no instance-member access. - Document that validateTimeZone throws an unchecked IllegalArgumentException, and why it is unchecked: the inherited run override declares no checked exception, matching the unchecked rejection the sibling policy execs use. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…yped JSON Rewrite the retention time-zone test as an OpenHouseSparkITest that runs SET POLICY through the OpenHouse catalog against the embedded tables service, then reads the stored policy back and parses it into the typed Policies model to assert the zone round-trips, instead of asserting on a substring of the raw property. Covers an IANA zone, a fixed offset, the no-zone case, and rejection of an unresolvable zone. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mkuchenbecker
force-pushed
the
mkuchenbecker/retention-timezone-grammar
branch
from
September 18, 2026 21:41
a0e31bc to
5a89a4a
Compare
mkuchenbecker
marked this pull request as ready for review
September 21, 2026 20:15
This branch has not been deployed
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.
Stack
Part of a stacked change (listed base first):
Based on #732. (#733 was merged into #732.)
Summary
Adds the SQL syntax for setting a retention time zone, so a table owner can configure it in place instead of through the REST policy object:
The zone is an IANA id such as
America/Los_Angelesor a fixed offset such as+05:30, and it works with or without a column pattern. The backend that measures retention in the zone is #732.Changes
Spark 3.5 extension only. The grammar gains an optional
WITH TIMEZONE '<zone>'clause on the retention policy;WITHandTIMEZONEare non-reserved, so they stay usable as identifiers. The parser carries the zone through theSetRetentionPolicyplan, and execution rejects a zone that Java'sZoneIdcannot resolve, then writes the policy (including the zone) as JSON with a JSON library. A statement with no clause writes the same policy as before.Testing Done
Java 17 integration test.
SetRetentionTimeZoneStatementTestrunsSET POLICY ... WITH TIMEZONEthrough the OpenHouse catalog against the embedded tables service, reads the stored policy back, and parses it into the typed policy model to check the zone round-trips. It covers an IANA zone, a fixed offset, the no-zone case, and rejection of an unresolvable zone.Additional Information
Based on #732 (backend core); #733 (zoned integration tests) was merged into #732. Scoped to the Spark 3.5 extension.
🤖 Generated with GitHub Copilot CLI