Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/10498#discussion_r49021259
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/WriterContainer.scala
---
@@ -342,22 +461,34 @@ private[sql] class DynamicPartitionWriterContainer(
// If anything below fails, we should abort the task.
try {
- // This will be filled in if we have to fall back on sorting.
- var sorter: UnsafeKVExternalSorter = null
+ // If there is no sorting columns, we set sorter to null and try the
hash-based writing first,
+ // and fill the sorter if there are too many writers and we need to
fall back on sorting.
+ // If there are sorting columns, then we have to sort the data
anyway, and no need to try the
--- End diff --
+1.
I'd vote for always do the sorting. In my benchmark, even for 1 or 2
partitions, hash based is only 10% faster than sort based one, but will reduce
the complicity a lot, especially when considering how to manage the memory for
writers. cc @marmbrus
---
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]