Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/8026#discussion_r42533868
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala
---
@@ -134,17 +137,38 @@ private[sql] object PartitioningUtils {
var finished = path.getParent == null
var chopped = path
+ var idx = 0 // the partition index from the right side of the path
while (!finished) {
+ val folderName = chopped.getName
// Sometimes (e.g., when speculative task is enabled), temporary
directories may be left
// uncleaned. Here we simply ignore them.
- if (chopped.getName.toLowerCase == "_temporary") {
+ if (folderName.toLowerCase == "_temporary") {
return None
}
- val maybeColumn = parsePartitionColumn(chopped.getName,
defaultPartitionName, typeInference)
- maybeColumn.foreach(columns += _)
+ folderName.split("=") match {
+ case Array(columnName, rawColumnValue) =>
+ val field = userDefinedPartitionColumns.map(struct =>
struct(struct.length - idx - 1))
+ assert(columnName.nonEmpty, s"Empty partition column name in
'$folderName'")
+ assert(field.isEmpty || (field.get.name == columnName))
+ assert(rawColumnValue.nonEmpty, s"Empty partition column value
in '$folderName'")
+
+ val literal = inferPartitionColumnValue(
+ field.map(_.dataType), rawColumnValue, defaultPartitionName,
typeInference)
+ columns += (columnName -> literal)
+
+ case Array(value) if folderName.startsWith("=") =>
+ throw new AssertionError(s"Empty partition column name in
'$folderName'")
--- End diff --
Is AssertionError the right exception to be throwing here? I'd think that
IllegalArgumentException might be more appropriate.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]