c21 commented on a change in pull request #32049:
URL: https://github.com/apache/spark/pull/32049#discussion_r606965650
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/parquet/ParquetPartitionReaderFactory.scala
##########
@@ -80,43 +88,135 @@ case class ParquetPartitionReaderFactory(
private val datetimeRebaseModeInRead =
parquetOptions.datetimeRebaseModeInRead
private val int96RebaseModeInRead = parquetOptions.int96RebaseModeInRead
+ private def buildAggSchema: StructType = {
+ var aggSchema = new StructType()
+ for (i <- 0 until aggregation.aggregateExpressions.size) {
+ var index = 0
+ aggregation.aggregateExpressions(i) match {
+ case Max(col, _) =>
+ index = dataSchema.fieldNames.toList.indexOf(col)
+ val field = dataSchema.fields(index)
+ aggSchema = aggSchema.add(field.copy("max(" + field.name + ")"))
+ case Min(col, _) =>
+ index = dataSchema.fieldNames.toList.indexOf(col)
+ val field = dataSchema.fields(index)
+ aggSchema = aggSchema.add(field.copy("min(" + field.name + ")"))
+ case Count(col, _, _) =>
+ if (col.equals("1")) {
+ aggSchema = aggSchema.add(new StructField("count(*)", LongType))
+ } else {
+ aggSchema = aggSchema.add(new StructField("count(" + col + ")",
LongType))
+ }
+ case _ =>
+ }
+ }
+ aggSchema
+ }
+
override def supportColumnarReads(partition: InputPartition): Boolean = {
sqlConf.parquetVectorizedReaderEnabled && sqlConf.wholeStageEnabled &&
resultSchema.length <= sqlConf.wholeStageMaxNumFields &&
resultSchema.forall(_.dataType.isInstanceOf[AtomicType])
}
override def buildReader(file: PartitionedFile):
PartitionReader[InternalRow] = {
- val reader = if (enableVectorizedReader) {
- createVectorizedReader(file)
+ val fileReader = if (aggregation.aggregateExpressions.isEmpty) {
+
+ val reader = if (enableVectorizedReader) {
+ createVectorizedReader(file)
Review comment:
It seems that it's supported to read aggregation result into a
`ColumnarBatch` below in `buildColumnarReader`. So we can still do aggregation
push down with vectorized reader enabled right?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]