huaxingao commented on a change in pull request #34445:
URL: https://github.com/apache/spark/pull/34445#discussion_r748808003
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/AggregatePushDownUtils.scala
##########
@@ -138,4 +145,39 @@ object AggregatePushDownUtils {
converter.convert(aggregatesAsRow, columnVectors.toArray)
new ColumnarBatch(columnVectors.asInstanceOf[Array[ColumnVector]], 1)
}
+
+ /**
+ * Return the schema for aggregates only (exclude group by columns)
+ */
+ def getSchemaWithoutGroupingExpression(
+ aggregation: Aggregation,
+ aggSchema: StructType): StructType = {
+ val numOfGroupByColumns = aggregation.groupByColumns.length
+ if (numOfGroupByColumns > 0) {
+ new StructType(aggSchema.fields.drop(numOfGroupByColumns))
+ } else {
+ aggSchema
+ }
+ }
+
+ /**
+ * Reorder partition cols if they are not in the same order as group by
columns
+ */
+ def reOrderPartitionCol(
+ partitionSchema: StructType,
+ aggregation: Aggregation,
+ partitionValues: InternalRow): InternalRow = {
+ val groupByColNames = aggregation.groupByColumns.map(_.fieldNames.head)
+ var reorderedPartColValues = Array.empty[Any]
+ if (!partitionSchema.names.sameElements(groupByColNames)) {
+ groupByColNames.foreach { col =>
+ val index = partitionSchema.names.indexOf(col)
+ val v = partitionValues.asInstanceOf[GenericInternalRow].values(index)
Review comment:
Seems to me that the `partitionValues` comes from `PartitionPath`, which
always contains `GenericInternalRow`.
--
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]