@@ -187,32 +187,9 @@ private[sql] object PartitioningUtils {
187
187
Seq .empty
188
188
} else {
189
189
val distinctPartColNames = pathsWithPartitionValues.map(_._2.columnNames).distinct
190
-
191
- def listConflictingPartitionColumns : String = {
192
- def groupByKey [K , V ](seq : Seq [(K , V )]): Map [K , Iterable [V ]] =
193
- seq.groupBy { case (key, _) => key }.mapValues(_.map { case (_, value) => value })
194
-
195
- val partColNamesToPaths = groupByKey(pathsWithPartitionValues.map {
196
- case (path, partValues) => partValues.columnNames -> path
197
- })
198
-
199
- val distinctPartColLists = distinctPartColNames.map(_.mkString(" , " )).zipWithIndex.map {
200
- case (names, index) =>
201
- s " Partition column name list # $index: $names"
202
- }
203
-
204
- // Lists out those non-leaf partition directories that also contain files
205
- val suspiciousPaths =
206
- distinctPartColNames.sortBy(_.length).init.flatMap(partColNamesToPaths)
207
-
208
- s " Conflicting partition column names detected: \n " +
209
- distinctPartColLists.mkString(" \n\t " , " \n\t " , " \n\n " ) +
210
- " For partitioned table directories, data files should only live in leaf directories. " +
211
- " Please check the following directories for unexpected files:\n " +
212
- suspiciousPaths.mkString(" \n\t " , " \n\t " , " \n " )
213
- }
214
-
215
- assert(distinctPartColNames.size == 1 , listConflictingPartitionColumns)
190
+ assert(
191
+ distinctPartColNames.size == 1 ,
192
+ listConflictingPartitionColumns(pathsWithPartitionValues))
216
193
217
194
// Resolves possible type conflicts for each column
218
195
val values = pathsWithPartitionValues.map(_._2)
@@ -228,6 +205,34 @@ private[sql] object PartitioningUtils {
228
205
}
229
206
}
230
207
208
+ private [sql] def listConflictingPartitionColumns (
209
+ pathWithPartitionValues : Seq [(Path , PartitionValues )]): String = {
210
+ val distinctPartColNames = pathWithPartitionValues.map(_._2.columnNames).distinct
211
+
212
+ def groupByKey [K , V ](seq : Seq [(K , V )]): Map [K , Iterable [V ]] =
213
+ seq.groupBy { case (key, _) => key }.mapValues(_.map { case (_, value) => value })
214
+
215
+ val partColNamesToPaths = groupByKey(pathWithPartitionValues.map {
216
+ case (path, partValues) => partValues.columnNames -> path
217
+ })
218
+
219
+ val distinctPartColLists = distinctPartColNames.map(_.mkString(" , " )).zipWithIndex.map {
220
+ case (names, index) =>
221
+ s " Partition column name list # $index: $names"
222
+ }
223
+
224
+ // Lists out those non-leaf partition directories that also contain files
225
+ val suspiciousPaths = distinctPartColNames.sortBy(_.length).flatMap(partColNamesToPaths)
226
+
227
+ s " Conflicting partition column names detected: \n " +
228
+ distinctPartColLists.mkString(" \n\t " , " \n\t " , " \n\n " ) +
229
+ " For partitioned table directories, data files should only live in leaf directories.\n " +
230
+ " And directories at the same level should have the same partition column name.\n " +
231
+ " Please check the following directories for unexpected files or " +
232
+ " inconsistent partition column names:\n " +
233
+ suspiciousPaths.map(" \t " + _).mkString(" \n " , " \n " , " " )
234
+ }
235
+
231
236
/**
232
237
* Converts a string to a [[Literal ]] with automatic type inference. Currently only supports
233
238
* [[IntegerType ]], [[LongType ]], [[DoubleType ]], [[DecimalType.Unlimited ]], and
0 commit comments