LuciferYang commented on code in PR #42839:
URL: https://github.com/apache/spark/pull/42839#discussion_r1318042923
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2ScanExecBase.scala:
##########
@@ -143,17 +143,16 @@ trait DataSourceV2ScanExecBase extends LeafExecNode {
// also sort the input partitions according to their partition key
order. This ensures
// a canonical order from both sides of a bucketed join, for example.
val partitionDataTypes = expressions.map(_.dataType)
- val partitionOrdering: Ordering[(InternalRow, InputPartition)] = {
-
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes).on(_._1)
- }
- val sortedKeyToPartitions = results.sorted(partitionOrdering)
- val groupedPartitions = sortedKeyToPartitions
+ val rowOrdering =
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes)
+ val sortedKeyToPartitions = results.sorted(rowOrdering.on(_._1))
+ val sortedGroupedPartitions = sortedKeyToPartitions
.map(t => (InternalRowComparableWrapper(t._1, expressions), t._2))
.groupBy(_._1)
.toSeq
.map { case (key, s) => KeyGroupedPartition(key.row, s.map(_._2)) }
+ .sorted(rowOrdering.on(_.value))
Review Comment:
```suggestion
.sorted(rowOrdering.on((k: KeyGroupedPartition) => k.value))
```
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2ScanExecBase.scala:
##########
@@ -143,17 +143,16 @@ trait DataSourceV2ScanExecBase extends LeafExecNode {
// also sort the input partitions according to their partition key
order. This ensures
// a canonical order from both sides of a bucketed join, for example.
val partitionDataTypes = expressions.map(_.dataType)
- val partitionOrdering: Ordering[(InternalRow, InputPartition)] = {
-
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes).on(_._1)
- }
- val sortedKeyToPartitions = results.sorted(partitionOrdering)
- val groupedPartitions = sortedKeyToPartitions
+ val rowOrdering =
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes)
+ val sortedKeyToPartitions = results.sorted(rowOrdering.on(_._1))
Review Comment:
To fix Scala 2.13 build
```
[error]
/home/runner/work/spark/spark/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2ScanExecBase.scala:147:67:
missing parameter type for expanded function ((<x$7: error>) => x$7._1)
[error] val sortedKeyToPartitions =
results.sorted(rowOrdering.on(_._1))
```
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2ScanExecBase.scala:
##########
@@ -143,17 +143,16 @@ trait DataSourceV2ScanExecBase extends LeafExecNode {
// also sort the input partitions according to their partition key
order. This ensures
// a canonical order from both sides of a bucketed join, for example.
val partitionDataTypes = expressions.map(_.dataType)
- val partitionOrdering: Ordering[(InternalRow, InputPartition)] = {
-
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes).on(_._1)
- }
- val sortedKeyToPartitions = results.sorted(partitionOrdering)
- val groupedPartitions = sortedKeyToPartitions
+ val rowOrdering =
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes)
+ val sortedKeyToPartitions = results.sorted(rowOrdering.on(_._1))
Review Comment:
```suggestion
val sortedKeyToPartitions = results.sorted(rowOrdering.on((t:
(InternalRow, _)) => t._1))
```
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2ScanExecBase.scala:
##########
@@ -143,17 +143,16 @@ trait DataSourceV2ScanExecBase extends LeafExecNode {
// also sort the input partitions according to their partition key
order. This ensures
// a canonical order from both sides of a bucketed join, for example.
val partitionDataTypes = expressions.map(_.dataType)
- val partitionOrdering: Ordering[(InternalRow, InputPartition)] = {
-
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes).on(_._1)
- }
- val sortedKeyToPartitions = results.sorted(partitionOrdering)
- val groupedPartitions = sortedKeyToPartitions
+ val rowOrdering =
RowOrdering.createNaturalAscendingOrdering(partitionDataTypes)
+ val sortedKeyToPartitions = results.sorted(rowOrdering.on(_._1))
+ val sortedGroupedPartitions = sortedKeyToPartitions
.map(t => (InternalRowComparableWrapper(t._1, expressions), t._2))
.groupBy(_._1)
.toSeq
.map { case (key, s) => KeyGroupedPartition(key.row, s.map(_._2)) }
+ .sorted(rowOrdering.on(_.value))
Review Comment:
ditto
--
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]