-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-49152][SQL][FOLLOWUP] table location string should be Hadoop Path string #47759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -373,8 +373,15 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager) | |
| serdeProperties, | ||
| partitionSpec) | ||
|
|
||
| case SetTableLocation(ResolvedV1TableIdentifier(ident), partitionSpec, location) => | ||
| AlterTableSetLocationCommand(ident, partitionSpec, location) | ||
| case SetTableLocation(ResolvedV1TableIdentifier(ident), None, location) => | ||
| AlterTableSetLocationCommand(ident, None, location) | ||
|
|
||
| // V2 catalog doesn't support setting partition location yet, we must use v1 command here. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not related to table location but is also a followup of #47660 to fix a missing case. |
||
| case SetTableLocation( | ||
| ResolvedTable(catalog, _, t: V1Table, _), | ||
| Some(partitionSpec), | ||
| location) if isSessionCatalog(catalog) => | ||
| AlterTableSetLocationCommand(t.v1Table.identifier, Some(partitionSpec), location) | ||
|
|
||
| case AlterViewAs(ResolvedViewIdentifier(ident), originalText, query) => | ||
| AlterViewAsCommand(ident, originalText, query) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ package org.apache.spark.sql.execution.datasources.v2 | |
|
|
||
| import scala.collection.mutable | ||
|
|
||
| import org.apache.hadoop.fs.Path | ||
|
|
||
| import org.apache.spark.SparkException | ||
| import org.apache.spark.internal.{Logging, MDC} | ||
| import org.apache.spark.internal.LogKeys.EXPR | ||
|
|
@@ -89,8 +91,19 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat | |
| } | ||
|
|
||
| private def qualifyLocInTableSpec(tableSpec: TableSpec): TableSpec = { | ||
| tableSpec.withNewLocation(tableSpec.location.map(loc => CatalogUtils.makeQualifiedPath( | ||
| CatalogUtils.stringToURI(loc), hadoopConf).toString)) | ||
| val newLoc = tableSpec.location.map { loc => | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code here follows |
||
| val locationUri = CatalogUtils.stringToURI(loc) | ||
| val qualified = if (locationUri.isAbsolute) { | ||
| locationUri | ||
| } else if (new Path(locationUri).isAbsolute) { | ||
| CatalogUtils.makeQualifiedPath(locationUri, hadoopConf) | ||
| } else { | ||
| // Leave it to the catalog implementation to qualify relative paths. | ||
| locationUri | ||
| } | ||
| CatalogUtils.URIToString(qualified) | ||
| } | ||
| tableSpec.withNewLocation(newLoc) | ||
| } | ||
|
|
||
| override def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,7 +78,7 @@ CREATE TABLE spark_catalog.default.tbl ( | |
| b STRING, | ||
| c INT) | ||
| USING parquet | ||
| LOCATION 'file:///path/to/table' | ||
| LOCATION 'file:/path/to/table' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've investigated this locally. The new result is actually consistent with the production behavior (with Hive Metastore). What happens is:
However, with This actually doesn't matter, as empty
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the details. |
||
|
|
||
|
|
||
| -- !query | ||
|
|
@@ -108,7 +108,7 @@ CREATE TABLE spark_catalog.default.tbl ( | |
| b STRING, | ||
| c INT) | ||
| USING parquet | ||
| LOCATION 'file:///path/to/table' | ||
| LOCATION 'file:/path/to/table' | ||
|
|
||
|
|
||
| -- !query | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for clarification.