Skip to content

Commit

Permalink
Fix path-based access for table redirect (delta-io#4163)
Browse files Browse the repository at this point in the history
<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Fix TableRedirect to allow path-based access.

## How was this patch tested?

Unit tests.

## Does this PR introduce _any_ user-facing changes?

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->
No.
  • Loading branch information
weiluo-db authored and anoopj committed Feb 24, 2025
1 parent 11f75e3 commit 0649844
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ class TableRedirect(val config: DeltaConfig[Option[String]]) {
val txn = deltaLog.startTransaction(catalogTableOpt)
val deltaMetadata = txn.snapshot.metadata
val currentConfigOpt = getRedirectConfiguration(deltaMetadata)
val tableIdent = catalogTableOpt.get.identifier.quotedString
val tableIdent = catalogTableOpt.map(_.identifier.quotedString).getOrElse {
s"delta.`${deltaLog.dataPath.toString}`"
}
// There should be an existing table redirect configuration.
if (currentConfigOpt.isEmpty) {
DeltaErrors.invalidRedirectStateTransition(tableIdent, NoRedirect, state)
Expand Down Expand Up @@ -332,7 +334,9 @@ class TableRedirect(val config: DeltaConfig[Option[String]]) {
val snapshot = txn.snapshot
getRedirectConfiguration(snapshot.metadata).foreach { currentConfig =>
DeltaErrors.invalidRedirectStateTransition(
catalogTableOpt.get.identifier.quotedString,
catalogTableOpt.map(_.identifier.quotedString).getOrElse {
s"delta.`${deltaLog.dataPath.toString}`"
},
currentConfig.redirectState,
EnableRedirectInProgress
)
Expand All @@ -353,7 +357,9 @@ class TableRedirect(val config: DeltaConfig[Option[String]]) {
def remove(deltaLog: DeltaLog, catalogTableOpt: Option[CatalogTable]): Unit = {
val txn = deltaLog.startTransaction(catalogTableOpt)
val currentConfigOpt = getRedirectConfiguration(txn.snapshot.metadata)
val tableIdent = catalogTableOpt.get.identifier.quotedString
val tableIdent = catalogTableOpt.map(_.identifier.quotedString).getOrElse {
s"delta.`${deltaLog.dataPath.toString}`"
}
if (currentConfigOpt.isEmpty) {
DeltaErrors.invalidRemoveTableRedirect(tableIdent, NoRedirect)
}
Expand Down
Loading

0 comments on commit 0649844

Please sign in to comment.