Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ class AuronSparkTestSettings extends SparkTestSettings {
// See https://github.com/apache/auron/issues/1724
.exclude("string / binary substring function")

enableSuite[AuronDataFrameAggregateSuite]
// See https://github.com/apache/auron/issues/1840
.excludeByPrefix("collect functions")
// A custom version of the SPARK-19471 test has been added to AuronDataFrameAggregateSuite
// with modified plan checks for Auron's native aggregates, so we exclude the original here.
.exclude(
"SPARK-19471: AggregationIterator does not initialize the generated result projection before using it")
.exclude(
"SPARK-24788: RelationalGroupedDataset.toString with unresolved exprs should not fail")

enableSuite[AuronDatasetAggregatorSuite]

enableSuite[AuronTypedImperativeAggregateSuite]

// Will be implemented in the future.
override def getSQLQueryTestSettings = new SQLQueryTestSettings {
override def getResourceFilePath: String = ???
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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.spark.sql

import scala.util.Random

import org.apache.spark.sql.execution.WholeStageCodegenExec
import org.apache.spark.sql.execution.aggregate.HashAggregateExec
import org.apache.spark.sql.execution.auron.plan.NativeAggBase
import org.apache.spark.sql.functions.{collect_list, monotonically_increasing_id, rand, randn, spark_partition_id, sum}
import org.apache.spark.sql.internal.SQLConf

class AuronDataFrameAggregateSuite extends DataFrameAggregateSuite with SparkQueryTestsBase {
import testImplicits._

// Ported from spark DataFrameAggregateSuite only with plan check changed.
private def assertNoExceptions(c: Column): Unit = {
for ((wholeStage, useObjectHashAgg) <-
Seq((true, true), (true, false), (false, true), (false, false))) {
withSQLConf(
(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, wholeStage.toString),
(SQLConf.USE_OBJECT_HASH_AGG.key, useObjectHashAgg.toString)) {

val df = Seq(("1", 1), ("1", 2), ("2", 3), ("2", 4)).toDF("x", "y")

val hashAggDF = df.groupBy("x").agg(c, sum("y"))
hashAggDF.collect()
val hashAggPlan = hashAggDF.queryExecution.executedPlan
if (wholeStage) {
assert(find(hashAggPlan) {
case WholeStageCodegenExec(_: HashAggregateExec) => true
// If offloaded, Spark whole stage codegen takes no effect and a native hash agg is
// expected to be used.
case _: NativeAggBase => true
case _ => false
}.isDefined)
} else {
assert(
stripAQEPlan(hashAggPlan).isInstanceOf[HashAggregateExec] ||
stripAQEPlan(hashAggPlan).find {
case _: NativeAggBase => true
case _ => false
}.isDefined)
}

val objHashAggOrSortAggDF = df.groupBy("x").agg(c, collect_list("y"))
objHashAggOrSortAggDF.collect()
assert(stripAQEPlan(objHashAggOrSortAggDF.queryExecution.executedPlan).find {
case _: NativeAggBase => true
case _ => false
}.isDefined)
}
}
}

testAuron(
"SPARK-19471: AggregationIterator does not initialize the generated result projection before using it") {
Seq(
monotonically_increasing_id(),
spark_partition_id(),
rand(Random.nextLong()),
randn(Random.nextLong())).foreach(assertNoExceptions)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.spark.sql

class AuronDatasetAggregatorSuite extends DatasetAggregatorSuite with SparkQueryTestsBase
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.spark.sql

class AuronTypedImperativeAggregateSuite
extends TypedImperativeAggregateSuite
with SparkQueryTestsBase
Loading