@@ -24,7 +24,8 @@ import org.apache.paimon.spark.data.SparkInternalRow
2424import org .apache .paimon .stats .SimpleStatsEvolutions
2525import org .apache .paimon .table .FileStoreTable
2626import org .apache .paimon .table .source .DataSplit
27- import org .apache .paimon .utils .{InternalRowUtils , ProjectedRow }
27+ import org .apache .paimon .types .RowType
28+ import org .apache .paimon .utils .ProjectedRow
2829
2930import org .apache .spark .sql .catalyst .InternalRow
3031import org .apache .spark .sql .catalyst .expressions .JoinedRow
@@ -40,7 +41,8 @@ class LocalAggregator(table: FileStoreTable) {
4041 private val partitionType = SparkTypeUtils .toPartitionType(table)
4142 private val groupByEvaluatorMap = new mutable.HashMap [InternalRow , Seq [AggFuncEvaluator [_]]]()
4243 private var requiredGroupByType : Seq [DataType ] = _
43- private var requiredGroupByIndexMapping : Seq [Int ] = _
44+ private var requiredGroupByIndexMapping : Array [Int ] = _
45+ private var requiredGroupByPaimonType : RowType = _
4446 private var aggFuncEvaluatorGetter : () => Seq [AggFuncEvaluator [_]] = _
4547 private var isInitialized = false
4648 private lazy val simpleStatsEvolutions = {
@@ -78,15 +80,14 @@ class LocalAggregator(table: FileStoreTable) {
7880 partitionType.getFieldIndex(r.fieldNames().head)
7981 }
8082
83+ requiredGroupByPaimonType = partitionType.project(requiredGroupByIndexMapping)
84+
8185 isInitialized = true
8286 }
8387
8488 private def requiredGroupByRow (partitionRow : BinaryRow ): InternalRow = {
85- val projectedRow =
86- ProjectedRow .from(requiredGroupByIndexMapping.toArray).replaceRow(partitionRow)
87- // `ProjectedRow` does not support `hashCode`, so do a deep copy
88- val genericRow = InternalRowUtils .copyInternalRow(projectedRow, partitionType)
89- SparkInternalRow .create(partitionType).replace(genericRow)
89+ val projectedRow = ProjectedRow .from(requiredGroupByIndexMapping).replaceRow(partitionRow)
90+ SparkInternalRow .create(requiredGroupByPaimonType).replace(projectedRow)
9091 }
9192
9293 def update (dataSplit : DataSplit ): Unit = {
0 commit comments