zhztheplayer commented on code in PR #5655:
URL: https://github.com/apache/incubator-gluten/pull/5655#discussion_r1596211736


##########
backends-velox/src/main/scala/org/apache/gluten/expression/aggregate/VeloxCollect.scala:
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gluten.expression.aggregate
+
+import org.apache.spark.sql.catalyst.expressions.{ArrayDistinct, ArrayUnion, 
AttributeReference, CreateArray, Expression, Literal}
+import org.apache.spark.sql.catalyst.expressions.aggregate.DeclarativeAggregate
+import org.apache.spark.sql.catalyst.trees.UnaryLike
+import org.apache.spark.sql.types.{ArrayType, DataType}
+
+abstract class VeloxCollect extends DeclarativeAggregate with 
UnaryLike[Expression] {
+  protected lazy val buffer: AttributeReference = AttributeReference("buffer", 
dataType)()
+
+  override def dataType: DataType = ArrayType(child.dataType, false)
+
+  override def aggBufferAttributes: Seq[AttributeReference] = List(buffer)
+
+  override lazy val initialValues: Seq[Expression] = 
List(Literal.create(Seq.empty, dataType))
+
+  override lazy val updateExpressions: Seq[Expression] = List(
+    ArrayUnion(buffer, CreateArray(List(child), useStringTypeWhenEmpty = 
false))

Review Comment:
   > For each row, we wrap a array. Will it cause performance regression with 
vanilla Spark ?
   
   Yes that's possible. But I assume it should be a comparatively rare case 
when user enables Gluten however these two functions are fallen back. So I 
think it's fine until getting real complaints from users. 



-- 
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]

Reply via email to