Github user kiszk commented on a diff in the pull request: https://github.com/apache/spark/pull/22187#discussion_r212075572 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/RowBasedHashMapGenerator.scala --- @@ -44,31 +44,19 @@ class RowBasedHashMapGenerator( groupingKeySchema, bufferSchema) { override protected def initializeAggregateHashMap(): String = { - val generatedKeySchema: String = - s"new org.apache.spark.sql.types.StructType()" + - groupingKeySchema.map { key => - val keyName = ctx.addReferenceObj("keyName", key.name) - key.dataType match { - case d: DecimalType => - s""".add($keyName, org.apache.spark.sql.types.DataTypes.createDecimalType( - |${d.precision}, ${d.scale}))""".stripMargin - case _ => - s""".add($keyName, org.apache.spark.sql.types.DataTypes.${key.dataType})""" - } - }.mkString("\n").concat(";") + val generatedKeyColTypes = groupingKeySchema + .zipWithIndex.map { case (t, i) => (s"_col$i", t.dataType) } + val generatedKeySchemaTypes = generatedKeyColTypes + .foldLeft(new StructType())((schema, colType) => schema.add(colType._1, colType._2)) --- End diff -- Ah, we do not need recreate the structure type. I think we do not need `.asNullable`. Furthermore, I think that we do not need `generatedAggBufferColTypes`. We need only # of its fields.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org