Skip to content

[spark] Preserve table-scoped options when resolving branches - #11679

Open
QuakeWang wants to merge 3 commits into
apache:masterfrom
QuakeWang:spark-branch-match
Open

QuakeWang wants to merge 3 commits into
apache:masterfrom
QuakeWang:spark-branch-match

Conversation

@QuakeWang

Copy link
Copy Markdown
Member

Purpose

Spark resolved the branch using the requested table name, then looked up options again using the branch-qualified name. With branch=dev and scan.snapshot-id=1 configured for the same table, the second lookup lost the snapshot option and returned rows from a later snapshot.

Resolve options once against the requested identifier, load the selected branch, and apply the remaining options to that table. Match identifier components literally so names such as sales(v2) and $audit_log work with table-scoped settings.

Tests

Added SQL coverage for branch selection, audit logs, and reading the first of two snapshots on dev. All 27 targeted tests passed on both Spark 3.5.9 and 4.1.4.

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>

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

[P2] Let explicit time travel override the configured default on a resolved branch.

On Spark 3.5.9 I created dev with snapshot 1 containing 2 and a later tag review_tag containing 2,3. I set the requested table's branch=dev and scan.snapshot-id=1 in SQLConf. The new ordinary read correctly returns [2]. An explicit SELECT id FROM rr_time_travel VERSION AS OF 'review_tag' then fails with must set only one key in [scan.snapshot-id,scan.tag-name,scan.watermark]. Removing the configured snapshot makes the same query return [2,3].

With the base SparkCatalog and OptionUtils restored on the same Spark classpath, the explicit query also returns [2,3] with that SQLConf set. Spark passes the explicit version separately in extraOptions. Please clear competing default time-travel selectors when applying an explicit SQL version or timestamp, while keeping the scoped defaults for ordinary reads. The 27 existing options tests passed.

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>

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

Thanks @QuakeWang for the updates! Both the default-branch (main) identifier handling and the interaction between branch resolution, session scan selectors, and explicit VERSION AS OF / TIMESTAMP AS OF time travel look clean and well-tested. LGTM!

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.

3 participants