dongjoon-hyun commented on code in PR #57243:
URL: https://github.com/apache/spark/pull/57243#discussion_r3580474310
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala:
##########
@@ -648,11 +648,13 @@ object PartitioningUtils extends SQLConfHelper {
* Given a collection of [[Literal]]s, resolves possible type conflicts by
* [[findWiderTypeForPartitionColumn]].
*/
- private def resolveTypeConflicts(typedValues: Seq[TypedPartValue]):
Seq[TypedPartValue] = {
+ private def resolveTypeConflicts(typedValues: Seq[TypedPartValue]):
IndexedSeq[TypedPartValue] = {
val dataTypes = typedValues.map(_.dataType)
val desiredType = dataTypes.reduce(findWiderTypeForPartitionColumn)
- typedValues.map(tv => tv.copy(dataType = desiredType))
+ // Returns IndexedSeq to guarantee O(1) element access at the call site.
+ // A linear Seq (like List) would cause O(n) lookups, making the
subsequent loop O(n²).
Review Comment:
While fixing this line, could you make this comment as a one-liner like the
following simply?
> IndexedSeq guarantees O(1) apply at the call site; a List would make the
loop O(n^2).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]