-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-19917][SQL]qualified partition path stored in catalog #17254
Conversation
@@ -1201,7 +1202,9 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils { | |||
verifyLocation(new URI("/swanky/steak/place")) | |||
// set table partition location without explicitly specifying database | |||
sql("ALTER TABLE tab1 PARTITION (a='1', b='2') SET LOCATION 'vienna'") | |||
verifyLocation(new URI("vienna"), Some(partSpec)) | |||
val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier("tab1")) |
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.
ALTER TABLE PARTITION SET LOCATION
relative location will be quallified with parent path using table location
assert(tableLocation.isDefined) | ||
makeQualifiedPath(new Path(tableLocation.get.toString, "paris").toString) | ||
} else { | ||
new URI("paris") |
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.
ALTER TABLE ADD PARTITION LOCATION
relative location will be quallified with parent path using table location
now InMemoryCatalog has the same action with HiveExternalCatalog
@@ -2180,6 +2181,13 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils { | |||
|
|||
withTempDir { dir => | |||
assert(!dir.getAbsolutePath.startsWith("file:/")) | |||
spark.sql(s"ALTER TABLE t SET LOCATION '$dir'") |
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.
ALTER TABLE SET LOCATION
should be also qualified
Test build #74373 has finished for PR 17254 at commit
|
Test build #74377 has started for PR 17254 at commit |
Test build #74378 has started for PR 17254 at commit |
retest this please |
Test build #74384 has finished for PR 17254 at commit
|
Test build #81437 has finished for PR 17254 at commit
|
Test build #95195 has started for PR 17254 at commit |
remove empty line remove empty line fix test failed fix test failed
36a3463
to
f59d65f
Compare
Test build #110779 has finished for PR 17254 at commit
|
retest this please |
Test build #110782 has finished for PR 17254 at commit
|
Test build #110783 has finished for PR 17254 at commit
|
&& !tableDefinition.storage.locationUri.get.isAbsolute) { | ||
// make the location of the table qualified. | ||
val qualifiedTableLocation = | ||
makeQualifiedPath(tableDefinition.storage.locationUri.get) |
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.
nit: 2 space indentation
@@ -942,7 +954,8 @@ class SessionCatalog( | |||
requireTableExists(TableIdentifier(table, Option(db))) | |||
requireExactMatchedPartitionSpec(parts.map(_.spec), getTableMetadata(tableName)) | |||
requireNonEmptyValueInPartitionSpec(parts.map(_.spec)) | |||
externalCatalog.alterPartitions(db, table, parts) | |||
|
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.
unnecessary blank line
Where is this done? |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
Show resolved
Hide resolved
Test build #110847 has finished for PR 17254 at commit
|
parts: Seq[CatalogTablePartition]): Seq[CatalogTablePartition] = { | ||
parts.map { part => | ||
if (part.storage.locationUri.isDefined && !part.storage.locationUri.get.isAbsolute) { | ||
val tbl = getTableMetadata(tableIdentifier) |
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.
we should get table metadata only once.
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.
we can mark it as lazy val in case we don't need to qualify any path.
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
Outdated
Show resolved
Hide resolved
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
Outdated
Show resolved
Hide resolved
Test build #111219 has finished for PR 17254 at commit
|
Test build #111222 has finished for PR 17254 at commit
|
Test build #111248 has finished for PR 17254 at commit
|
thanks, merging to master! |
What changes were proposed in this pull request?
partition path should be qualified to store in catalog.
There are some scenes:
should be qualified: file:/path/x
Hive 2.0.0 does not support for location without schema here.
should be qualified: file:/tablelocation/x
Hive 2.0.0 does not support for relative location here.
should be qualified: file:/path/x
the same with Hive 2.0.0
should be qualified: file:/tablelocation/x
the same with Hive 2.0.0
Currently only ALTER TABLE t ADD PARTITION(b=1) LOCATION for hive serde table has the expected qualified path. we should make other scenes to be consist with it.
Another change is for alter table location.
How was this patch tested?
add / modify existing TestCases