From ea7a71bebf07764fee0ad2c361ca56950de9002b Mon Sep 17 00:00:00 2001 From: lyne7-sc <734432041@qq.com> Date: Thu, 7 May 2026 23:12:11 +0800 Subject: [PATCH 1/3] add functions suites for spark3x --- .../spark/sql/SparkQueryTestsBase.scala | 12 +++---- .../auron/utils/AuronSparkTestSettings.scala | 32 +++++++++++++++++ .../sql/AuronDataFrameFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronDateFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMathFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMiscFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronStringFunctionsSuite.scala | 19 ++++++++++ .../auron/utils/AuronSparkTestSettings.scala | 32 +++++++++++++++++ .../sql/AuronDataFrameFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronDateFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMathFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMiscFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronStringFunctionsSuite.scala | 19 ++++++++++ .../auron/utils/AuronSparkTestSettings.scala | 34 ++++++++++++++++++ .../sql/AuronDataFrameFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronDateFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMathFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMiscFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronStringFunctionsSuite.scala | 19 ++++++++++ .../auron/utils/AuronSparkTestSettings.scala | 35 +++++++++++++++++++ .../sql/AuronDataFrameFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronDateFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMathFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronMiscFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/AuronStringFunctionsSuite.scala | 19 ++++++++++ .../spark/sql/auron/AuronConverters.scala | 6 ++-- .../auron/AuronSparkSessionExtension.scala | 2 +- .../apache/spark/sql/auron/NativeHelper.scala | 2 +- .../sql/auron/util/TaskContextHelper.scala | 2 +- 29 files changed, 525 insertions(+), 12 deletions(-) create mode 100644 auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala create mode 100644 auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala create mode 100644 auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala create mode 100644 auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala create mode 100644 auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala create mode 100644 auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala create mode 100644 auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala create mode 100644 auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala create mode 100644 auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala create mode 100644 auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala create mode 100644 auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala create mode 100644 auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala create mode 100644 auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala create mode 100644 auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala create mode 100644 auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala create mode 100644 auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala create mode 100644 auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala create mode 100644 auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala create mode 100644 auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala create mode 100644 auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala diff --git a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala index 159cb6174..1421919f9 100644 --- a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala +++ b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala @@ -176,12 +176,12 @@ object AuronQueryTestUtil extends Assertions { s""" |== Results == |${sideBySide( - s"== Correct Answer - ${expectedAnswer.size} ==" +: - getRowType(expectedAnswer.headOption) +: - prepareAnswer(expectedAnswer, isSorted).map(_.toString()), - s"== Auron Answer - ${sparkAnswer.size} ==" +: - getRowType(sparkAnswer.headOption) +: - prepareAnswer(sparkAnswer, isSorted).map(_.toString())).mkString("\n")} + s"== Correct Answer - ${expectedAnswer.size} ==" +: + getRowType(expectedAnswer.headOption) +: + prepareAnswer(expectedAnswer, isSorted).map(_.toString()), + s"== Auron Answer - ${sparkAnswer.size} ==" +: + getRowType(sparkAnswer.headOption) +: + prepareAnswer(sparkAnswer, isSorted).map(_.toString())).mkString("\n")} """.stripMargin } diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index 052cca5d1..b1a5bbfc4 100644 --- a/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -16,7 +16,39 @@ */ package org.apache.auron.utils +import org.apache.spark.sql._ + class AuronSparkTestSettings extends SparkTestSettings { + { + // Use Arrow's unsafe implementation. + System.setProperty("arrow.allocation.manager.type", "Unsafe") + } + + enableSuite[AuronDataFrameFunctionsSuite] + .exclude("map with arrays") + .exclude("map_concat function") + .exclude("reverse function - array for primitive type not containing null") + .exclude("reverse function - array for primitive type containing null") + .exclude("reverse function - array for non-primitive type") + .exclude("flatten function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + + enableSuite[AuronDateFunctionsSuite] + .exclude("function to_date") + .exclude("function date_trunc") + .exclude("unsupported fmt fields for trunc/date_trunc results null") + .exclude("unix_timestamp") + .exclude("to_unix_timestamp") + .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") + + enableSuite[AuronMathFunctionsSuite] + .exclude("acosh") + + enableSuite[AuronMiscFunctionsSuite] + + enableSuite[AuronStringFunctionsSuite] + .exclude("string / binary substring function") + override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { override def getResourceFilePath: String = "" override def getSupportedSQLQueryTests: Set[String] = Set.empty diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala new file mode 100644 index 000000000..98448e333 --- /dev/null +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala @@ -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 AuronDataFrameFunctionsSuite extends DataFrameFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala new file mode 100644 index 000000000..dddef76fb --- /dev/null +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala @@ -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 AuronDateFunctionsSuite extends DateFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala new file mode 100644 index 000000000..eb2d96a9b --- /dev/null +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala @@ -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 AuronMathFunctionsSuite extends MathFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala new file mode 100644 index 000000000..a50ff3367 --- /dev/null +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala @@ -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 AuronMiscFunctionsSuite extends MiscFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala new file mode 100644 index 000000000..bd621ba17 --- /dev/null +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala @@ -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 AuronStringFunctionsSuite extends StringFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index 052cca5d1..b1a5bbfc4 100644 --- a/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -16,7 +16,39 @@ */ package org.apache.auron.utils +import org.apache.spark.sql._ + class AuronSparkTestSettings extends SparkTestSettings { + { + // Use Arrow's unsafe implementation. + System.setProperty("arrow.allocation.manager.type", "Unsafe") + } + + enableSuite[AuronDataFrameFunctionsSuite] + .exclude("map with arrays") + .exclude("map_concat function") + .exclude("reverse function - array for primitive type not containing null") + .exclude("reverse function - array for primitive type containing null") + .exclude("reverse function - array for non-primitive type") + .exclude("flatten function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + + enableSuite[AuronDateFunctionsSuite] + .exclude("function to_date") + .exclude("function date_trunc") + .exclude("unsupported fmt fields for trunc/date_trunc results null") + .exclude("unix_timestamp") + .exclude("to_unix_timestamp") + .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") + + enableSuite[AuronMathFunctionsSuite] + .exclude("acosh") + + enableSuite[AuronMiscFunctionsSuite] + + enableSuite[AuronStringFunctionsSuite] + .exclude("string / binary substring function") + override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { override def getResourceFilePath: String = "" override def getSupportedSQLQueryTests: Set[String] = Set.empty diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala new file mode 100644 index 000000000..98448e333 --- /dev/null +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala @@ -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 AuronDataFrameFunctionsSuite extends DataFrameFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala new file mode 100644 index 000000000..dddef76fb --- /dev/null +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala @@ -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 AuronDateFunctionsSuite extends DateFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala new file mode 100644 index 000000000..eb2d96a9b --- /dev/null +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala @@ -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 AuronMathFunctionsSuite extends MathFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala new file mode 100644 index 000000000..a50ff3367 --- /dev/null +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala @@ -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 AuronMiscFunctionsSuite extends MiscFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala new file mode 100644 index 000000000..bd621ba17 --- /dev/null +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala @@ -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 AuronStringFunctionsSuite extends StringFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index 052cca5d1..f5881a704 100644 --- a/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -16,7 +16,41 @@ */ package org.apache.auron.utils +import org.apache.spark.sql._ + class AuronSparkTestSettings extends SparkTestSettings { + { + // Use Arrow's unsafe implementation. + System.setProperty("arrow.allocation.manager.type", "Unsafe") + } + + enableSuite[AuronDataFrameFunctionsSuite] + .exclude("map with arrays") + .exclude("map_concat function") + .exclude("reverse function - array for primitive type not containing null") + .exclude("reverse function - array for primitive type containing null") + .exclude("reverse function - array for non-primitive type") + .exclude("flatten function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + .exclude("array_insert functions") + .exclude("transform keys function - Invalid lambda functions and exceptions") + + enableSuite[AuronDateFunctionsSuite] + .exclude("function to_date") + .exclude("function date_trunc") + .exclude("unsupported fmt fields for trunc/date_trunc results null") + .exclude("unix_timestamp") + .exclude("to_unix_timestamp") + .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") + + enableSuite[AuronMathFunctionsSuite] + .exclude("acosh") + + enableSuite[AuronMiscFunctionsSuite] + + enableSuite[AuronStringFunctionsSuite] + .exclude("string / binary substring function") + override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { override def getResourceFilePath: String = "" override def getSupportedSQLQueryTests: Set[String] = Set.empty diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala new file mode 100644 index 000000000..98448e333 --- /dev/null +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala @@ -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 AuronDataFrameFunctionsSuite extends DataFrameFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala new file mode 100644 index 000000000..dddef76fb --- /dev/null +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala @@ -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 AuronDateFunctionsSuite extends DateFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala new file mode 100644 index 000000000..eb2d96a9b --- /dev/null +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala @@ -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 AuronMathFunctionsSuite extends MathFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala new file mode 100644 index 000000000..a50ff3367 --- /dev/null +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala @@ -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 AuronMiscFunctionsSuite extends MiscFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala new file mode 100644 index 000000000..bd621ba17 --- /dev/null +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala @@ -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 AuronStringFunctionsSuite extends StringFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index 052cca5d1..edb478685 100644 --- a/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -16,7 +16,42 @@ */ package org.apache.auron.utils +import org.apache.spark.sql._ + class AuronSparkTestSettings extends SparkTestSettings { + { + // Use Arrow's unsafe implementation. + System.setProperty("arrow.allocation.manager.type", "Unsafe") + } + + enableSuite[AuronDataFrameFunctionsSuite] + .exclude("map with arrays") + .exclude("map_concat function") + .exclude("reverse function - array for primitive type not containing null") + .exclude("reverse function - array for primitive type containing null") + .exclude("reverse function - array for non-primitive type") + .exclude("flatten function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + .exclude("array_insert functions") + .exclude("transform keys function - Invalid lambda functions and exceptions") + + enableSuite[AuronDateFunctionsSuite] + .exclude("function to_date") + .exclude("function date_trunc") + .exclude("unsupported fmt fields for trunc/date_trunc results null") + .exclude("unix_timestamp") + .exclude("to_unix_timestamp") + .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") + + enableSuite[AuronMathFunctionsSuite] + .exclude("acosh") + + enableSuite[AuronMiscFunctionsSuite] + + enableSuite[AuronStringFunctionsSuite] + .exclude("string Levenshtein distance") + .exclude("string / binary substring function") + override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { override def getResourceFilePath: String = "" override def getSupportedSQLQueryTests: Set[String] = Set.empty diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala new file mode 100644 index 000000000..98448e333 --- /dev/null +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala @@ -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 AuronDataFrameFunctionsSuite extends DataFrameFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala new file mode 100644 index 000000000..dddef76fb --- /dev/null +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala @@ -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 AuronDateFunctionsSuite extends DateFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala new file mode 100644 index 000000000..eb2d96a9b --- /dev/null +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala @@ -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 AuronMathFunctionsSuite extends MathFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala new file mode 100644 index 000000000..a50ff3367 --- /dev/null +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala @@ -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 AuronMiscFunctionsSuite extends MiscFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala new file mode 100644 index 000000000..bd621ba17 --- /dev/null +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala @@ -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 AuronStringFunctionsSuite extends StringFunctionsSuite with SparkQueryTestsBase {} diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala index cc12a176a..cfdf4f86c 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala @@ -429,7 +429,7 @@ object AuronConverters extends Logging { assert( !exec.requiredSchema.exists(e => existTimestampType(e.dataType)), s"Parquet scan with timestamp type is not supported for table: ${tableIdentifier - .getOrElse("unknown")}. " + + .getOrElse("unknown")}. " + "Set spark.auron.enable.scan.parquet.timestamp=true to enable timestamp support " + "or remove timestamp columns from the query.") } @@ -440,7 +440,7 @@ object AuronConverters extends Logging { assert( !exec.requiredSchema.exists(e => existTimestampType(e.dataType)), s"ORC scan with timestamp type is not supported for tableIdentifier: ${tableIdentifier - .getOrElse("unknown")}. " + + .getOrElse("unknown")}. " + "Set spark.auron.enable.scan.orc.timestamp=true to enable timestamp support " + "or remove timestamp columns from the query.") } @@ -448,7 +448,7 @@ object AuronConverters extends Logging { case p => throw new NotImplementedError( s"Cannot convert FileSourceScanExec tableIdentifier: ${tableIdentifier.getOrElse( - "unknown")}, class: ${p.getClass.getName}") + "unknown")}, class: ${p.getClass.getName}") } } diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala index b68b04954..47492aa3d 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala @@ -91,7 +91,7 @@ case class AuronColumnarOverrides(sparkSession: SparkSession) extends ColumnarRu dumpSimpleSparkPlanTreeNode(sparkPlanTransformed) logInfo(s"Transformed spark plan after preColumnarTransitions:\n${sparkPlanTransformed - .treeString(verbose = true, addSuffix = true)}") + .treeString(verbose = true, addSuffix = true)}") // post-transform Shims.get.postTransform(sparkPlanTransformed, sparkSession.sparkContext) diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala index e16656471..7a1e34724 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala @@ -74,7 +74,7 @@ object NativeHelper extends Logging { val heapMemory = Runtime.getRuntime.maxMemory() val offheapMemory = totalMemory - heapMemory logWarning(s"memory total: ${Utils.bytesToString(totalMemory)}, onheap: ${Utils.bytesToString( - heapMemory)}, offheap: ${Utils.bytesToString(offheapMemory)}") + heapMemory)}, offheap: ${Utils.bytesToString(offheapMemory)}") offheapMemory } diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala index 309139ebf..37d012cc7 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala @@ -47,7 +47,7 @@ object TaskContextHelper extends Logging { val thread = Thread.currentThread() val threadPrefix = if (context != null) { s"auron native task ${context.partitionId()}.${context.attemptNumber()} in stage ${context - .stageId()}.${context.stageAttemptNumber()} (TID ${context.taskAttemptId()})" + .stageId()}.${context.stageAttemptNumber()} (TID ${context.taskAttemptId()})" } else { "auron native task" } From eaae81a6f4d280de4aaad511ff4454e3f44bbc00 Mon Sep 17 00:00:00 2001 From: lyne7-sc <734432041@qq.com> Date: Fri, 8 May 2026 21:49:48 +0800 Subject: [PATCH 2/3] add functions suites for spark4x --- .../spark/sql/SparkExpressionTestsBase.scala | 55 +++++++++++++------ .../spark/sql/SparkQueryTestsBase.scala | 4 +- .../auron/utils/AuronSparkTestSettings.scala | 18 ++++++ .../auron/utils/AuronSparkTestSettings.scala | 19 ++++++- .../auron/utils/AuronSparkTestSettings.scala | 22 ++++++-- .../auron/utils/AuronSparkTestSettings.scala | 23 ++++++-- .../auron/utils/AuronSparkTestSettings.scala | 48 ++++++++++++++++ .../sql/AuronDataFrameFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronDateFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronMathFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronMiscFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronStringFunctionsSuite.scala | 19 +++++++ .../auron/utils/AuronSparkTestSettings.scala | 48 ++++++++++++++++ .../sql/AuronDataFrameFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronDateFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronMathFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronMiscFunctionsSuite.scala | 19 +++++++ .../spark/sql/AuronStringFunctionsSuite.scala | 19 +++++++ 18 files changed, 395 insertions(+), 32 deletions(-) create mode 100644 auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala create mode 100644 auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala create mode 100644 auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala create mode 100644 auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala create mode 100644 auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala create mode 100644 auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala create mode 100644 auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala create mode 100644 auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala create mode 100644 auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala create mode 100644 auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala diff --git a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala index 14490aef0..8a6750f5e 100644 --- a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala +++ b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala @@ -23,6 +23,7 @@ import scala.collection.mutable.ArrayBuffer import org.apache.commons.io.FileUtils import org.apache.commons.math3.util.Precision +import org.apache.auron.sparkver import org.apache.spark.SparkFunSuite import org.apache.spark.sql.catalyst.{CatalystTypeConverters, InternalRow} import org.apache.spark.sql.catalyst.analysis.ResolveTimeZone @@ -143,7 +144,7 @@ trait SparkExpressionTestsBase val empData = Seq(Row(1)) _spark.createDataFrame(_spark.sparkContext.parallelize(empData), schema) } - val resultDF = df.select(Column(expression)) + val resultDF = df.select(columnFromExpression(expression)) val result = resultDF.collect() if (checkDataTypeSupported(expression) && @@ -296,23 +297,18 @@ trait SparkExpressionTestsBase */ private def canConvertToDataFrame(inputRow: InternalRow): Boolean = { if (inputRow == EmptyRow || inputRow == InternalRow.empty) { - return true - } - - if (!inputRow.isInstanceOf[GenericInternalRow]) { - return false - } - - val values = inputRow.asInstanceOf[GenericInternalRow].values - for (value <- values) { - value match { - case _: MapData => return false - case _: ArrayData => return false - case _: InternalRow => return false - case _ => + true + } else if (!inputRow.isInstanceOf[GenericInternalRow]) { + false + } else { + val values = inputRow.asInstanceOf[GenericInternalRow].values + values.forall { + case _: MapData => false + case _: ArrayData => false + case _: InternalRow => false + case _ => true } } - true } private def convertInternalRowToDataFrame(inputRow: InternalRow): DataFrame = { @@ -350,8 +346,33 @@ trait SparkExpressionTestsBase structFieldSeq.append(StructField("n", IntegerType, nullable = true)) } - _spark.internalCreateDataFrame( + internalCreateDataFrame( _spark.sparkContext.parallelize(Seq(inputRow)), StructType(structFieldSeq.toSeq)) } + + @sparkver("3.0 / 3.1 / 3.2 / 3.3 / 3.4 / 3.5") + private def columnFromExpression(expression: Expression): Column = { + Column(expression) + } + + @sparkver("4.0 / 4.1") + private def columnFromExpression(expression: Expression): Column = { + new Column(org.apache.spark.sql.classic.ExpressionColumnNode(expression)) + } + + @sparkver("3.0 / 3.1 / 3.2 / 3.3 / 3.4 / 3.5") + private def internalCreateDataFrame( + rows: org.apache.spark.rdd.RDD[InternalRow], + schema: StructType): DataFrame = { + _spark.internalCreateDataFrame(rows, schema) + } + + @sparkver("4.0 / 4.1") + private def internalCreateDataFrame( + rows: org.apache.spark.rdd.RDD[InternalRow], + schema: StructType): org.apache.spark.sql.classic.DataFrame = { + _spark.asInstanceOf[org.apache.spark.sql.classic.SparkSession] + .internalCreateDataFrame(rows, schema) + } } diff --git a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala index 1421919f9..e99146ed1 100644 --- a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala +++ b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala @@ -91,9 +91,9 @@ object AuronQueryTestUtil extends Assertions { df: DataFrame, expectedAnswer: Seq[Row], checkToRDD: Boolean = true): Option[String] = { - val isSorted = df.logicalPlan.collect { case s: logical.Sort => s }.nonEmpty + val isSorted = df.queryExecution.logical.collect { case s: logical.Sort => s }.nonEmpty if (checkToRDD) { - SQLExecution.withSQLConfPropagated(df.sparkSession) { + SQLExecution.withSQLConfPropagated(df.queryExecution.sparkSession) { df.rdd.count() // Also attempt to deserialize as an RDD [SPARK-15791] } } diff --git a/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index b1a5bbfc4..331724bf7 100644 --- a/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark31/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -24,29 +24,47 @@ class AuronSparkTestSettings extends SparkTestSettings { System.setProperty("arrow.allocation.manager.type", "Unsafe") } + + enableSuite[AuronDataFrameFunctionsSuite] + // Native execution wraps SparkRuntimeException from map construction in SparkException. .exclude("map with arrays") + // Native execution wraps SparkRuntimeException from map_concat input validation in + // SparkException. .exclude("map_concat function") + // Native reverse only supports string inputs; array inputs fail with unsupported List type. .exclude("reverse function - array for primitive type not containing null") .exclude("reverse function - array for primitive type containing null") .exclude("reverse function - array for non-primitive type") + // Native flatten can fail when child arrays have different containsNull metadata. .exclude("flatten function") + // Native execution wraps SparkRuntimeException from null map keys in SparkException. .exclude("SPARK-24734: Fix containsNull of Concat for array type") enableSuite[AuronDateFunctionsSuite] + // Native execution wraps SparkUpgradeException from parsing validation in SparkException. .exclude("function to_date") + // Native date_trunc does not support all Spark granularity aliases. .exclude("function date_trunc") + // Native date_trunc throws for unsupported fields instead of returning NULL as Spark does. .exclude("unsupported fmt fields for trunc/date_trunc results null") + // Native execution wraps SparkUpgradeException from parsing validation in SparkException. .exclude("unix_timestamp") + // Native execution wraps IllegalArgumentException from format validation in SparkException. .exclude("to_unix_timestamp") + // Native date_trunc may produce incorrect results for historical timestamps with + // non-UTC timezones due to timezone handling differences in the DataFusion engine. .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") enableSuite[AuronMathFunctionsSuite] + // Native acosh uses a different floating-point formula than Spark's StrictMath.log, + // producing results that differ at the last ULP for certain edge-case inputs. .exclude("acosh") enableSuite[AuronMiscFunctionsSuite] enableSuite[AuronStringFunctionsSuite] + // See https://github.com/apache/auron/issues/1724 .exclude("string / binary substring function") override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { diff --git a/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index b1a5bbfc4..cca7adc88 100644 --- a/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark32/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -25,28 +25,41 @@ class AuronSparkTestSettings extends SparkTestSettings { } enableSuite[AuronDataFrameFunctionsSuite] + // Native execution wraps SparkRuntimeException from map-related validation in + // SparkException. .exclude("map with arrays") .exclude("map_concat function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + // Native reverse only supports string inputs; array inputs fail with unsupported List type. .exclude("reverse function - array for primitive type not containing null") .exclude("reverse function - array for primitive type containing null") .exclude("reverse function - array for non-primitive type") + // Native flatten can fail when child arrays have different containsNull metadata. .exclude("flatten function") - .exclude("SPARK-24734: Fix containsNull of Concat for array type") enableSuite[AuronDateFunctionsSuite] + // Native execution wraps Spark parsing/format validation exceptions in SparkException. .exclude("function to_date") - .exclude("function date_trunc") - .exclude("unsupported fmt fields for trunc/date_trunc results null") .exclude("unix_timestamp") .exclude("to_unix_timestamp") + // Native date_trunc does not support all Spark granularity aliases. + .exclude("function date_trunc") + // Native date_trunc throws for unsupported fields instead of returning NULL as Spark does. + .exclude("unsupported fmt fields for trunc/date_trunc results null") + // Native date_trunc may produce incorrect results for historical timestamps with + // non-UTC timezones due to timezone handling differences in the DataFusion engine. .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") enableSuite[AuronMathFunctionsSuite] + // Native acosh uses a different floating-point formula than Spark's StrictMath.log, + // producing results that differ at the last ULP for certain edge-case inputs. .exclude("acosh") enableSuite[AuronMiscFunctionsSuite] enableSuite[AuronStringFunctionsSuite] + // Native substr does not support BinaryType inputs. + // See https://github.com/apache/auron/issues/1724 .exclude("string / binary substring function") override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { diff --git a/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index f5881a704..150fe7b4b 100644 --- a/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark34/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -25,30 +25,42 @@ class AuronSparkTestSettings extends SparkTestSettings { } enableSuite[AuronDataFrameFunctionsSuite] + // Native execution wraps SparkRuntimeException from validation failures in SparkException. .exclude("map with arrays") .exclude("map_concat function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + .exclude("array_insert functions") + .exclude("transform keys function - Invalid lambda functions and exceptions") + // Native reverse only supports string inputs; array inputs fail with unsupported List type. .exclude("reverse function - array for primitive type not containing null") .exclude("reverse function - array for primitive type containing null") .exclude("reverse function - array for non-primitive type") + // Native flatten can fail when child arrays have different containsNull metadata. .exclude("flatten function") - .exclude("SPARK-24734: Fix containsNull of Concat for array type") - .exclude("array_insert functions") - .exclude("transform keys function - Invalid lambda functions and exceptions") enableSuite[AuronDateFunctionsSuite] + // Native execution wraps Spark parsing/format validation exceptions in SparkException. .exclude("function to_date") - .exclude("function date_trunc") - .exclude("unsupported fmt fields for trunc/date_trunc results null") .exclude("unix_timestamp") .exclude("to_unix_timestamp") + // Native date_trunc does not support all Spark granularity aliases. + .exclude("function date_trunc") + // Native date_trunc throws for unsupported fields instead of returning NULL as Spark does. + .exclude("unsupported fmt fields for trunc/date_trunc results null") + // Native date_trunc may produce incorrect results for historical timestamps with + // non-UTC timezones due to timezone handling differences in the DataFusion engine. .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") enableSuite[AuronMathFunctionsSuite] + // Native acosh uses a different floating-point formula than Spark's StrictMath.log, + // producing results that differ at the last ULP for certain edge-case inputs. .exclude("acosh") enableSuite[AuronMiscFunctionsSuite] enableSuite[AuronStringFunctionsSuite] + // Native substr does not support BinaryType inputs. + // See https://github.com/apache/auron/issues/1724 .exclude("string / binary substring function") override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { diff --git a/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index edb478685..697e314a4 100644 --- a/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark35/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -25,31 +25,44 @@ class AuronSparkTestSettings extends SparkTestSettings { } enableSuite[AuronDataFrameFunctionsSuite] + // Native execution wraps SparkRuntimeException from validation failures in SparkException. .exclude("map with arrays") .exclude("map_concat function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + .exclude("array_insert functions") + .exclude("transform keys function - Invalid lambda functions and exceptions") + // Native reverse only supports string inputs; array inputs fail with unsupported List type. .exclude("reverse function - array for primitive type not containing null") .exclude("reverse function - array for primitive type containing null") .exclude("reverse function - array for non-primitive type") + // Native flatten can fail when child arrays have different containsNull metadata. .exclude("flatten function") - .exclude("SPARK-24734: Fix containsNull of Concat for array type") - .exclude("array_insert functions") - .exclude("transform keys function - Invalid lambda functions and exceptions") enableSuite[AuronDateFunctionsSuite] + // Native execution wraps Spark parsing/format validation exceptions in SparkException. .exclude("function to_date") - .exclude("function date_trunc") - .exclude("unsupported fmt fields for trunc/date_trunc results null") .exclude("unix_timestamp") .exclude("to_unix_timestamp") + // Native date_trunc does not support all Spark granularity aliases. + .exclude("function date_trunc") + // Native date_trunc throws for unsupported fields instead of returning NULL as Spark does. + .exclude("unsupported fmt fields for trunc/date_trunc results null") + // Native date_trunc may produce incorrect results for historical timestamps with + // non-UTC timezones due to timezone handling differences in the DataFusion engine. .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") enableSuite[AuronMathFunctionsSuite] + // Native acosh uses a different floating-point formula than Spark's StrictMath.log, + // producing results that differ at the last ULP for certain edge-case inputs. .exclude("acosh") enableSuite[AuronMiscFunctionsSuite] enableSuite[AuronStringFunctionsSuite] + // Native levenshtein has a Spark 3.5+ result or schema comparison mismatch. .exclude("string Levenshtein distance") + // Native substr does not support BinaryType inputs. + // See https://github.com/apache/auron/issues/1724 .exclude("string / binary substring function") override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { diff --git a/auron-spark-tests/spark40/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark40/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index 052cca5d1..a04eaebe1 100644 --- a/auron-spark-tests/spark40/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark40/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -16,7 +16,55 @@ */ package org.apache.auron.utils +import org.apache.spark.sql._ + class AuronSparkTestSettings extends SparkTestSettings { + { + // Use Arrow's unsafe implementation. + System.setProperty("arrow.allocation.manager.type", "Unsafe") + } + + enableSuite[AuronDataFrameFunctionsSuite] + // Native execution wraps SparkRuntimeException from validation failures in SparkException. + .exclude("map with arrays") + .exclude("map_concat function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + .exclude("array_insert functions") + .exclude("transform keys function - Invalid lambda functions and exceptions") + // Native reverse only supports string inputs; array inputs fail with unsupported List type. + .exclude("reverse function - array for primitive type not containing null") + .exclude("reverse function - array for primitive type containing null") + .exclude("reverse function - array for non-primitive type") + // Native flatten can panic when child arrays have different containsNull metadata. + .exclude("flatten function") + + enableSuite[AuronDateFunctionsSuite] + // Native execution wraps Spark parsing/format validation exceptions in SparkException. + .exclude("function to_date") + .exclude("unix_timestamp") + .exclude("to_unix_timestamp") + // Native date_trunc does not support all Spark aliases such as "yy". + .exclude("function date_trunc") + // Native date_trunc throws for unsupported fields instead of returning NULL as Spark does. + .exclude("unsupported fmt fields for trunc/date_trunc results null") + // Native date_trunc may produce incorrect results for historical timestamps with + // non-UTC timezones due to timezone handling differences in the DataFusion engine. + .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") + + enableSuite[AuronMathFunctionsSuite] + // Native acosh uses a different floating-point formula than Spark's StrictMath.log, + // producing results that differ at the last ULP for certain edge-case inputs. + .exclude("acosh") + + enableSuite[AuronMiscFunctionsSuite] + + enableSuite[AuronStringFunctionsSuite] + // Spark 4 adds the threshold argument, but native levenshtein currently supports only + // two arguments. + .exclude("string Levenshtein distance") + // Native substr does not support BinaryType inputs. + .exclude("string / binary substring function") + override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { override def getResourceFilePath: String = "" override def getSupportedSQLQueryTests: Set[String] = Set.empty diff --git a/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala new file mode 100644 index 000000000..98448e333 --- /dev/null +++ b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala @@ -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 AuronDataFrameFunctionsSuite extends DataFrameFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala new file mode 100644 index 000000000..dddef76fb --- /dev/null +++ b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala @@ -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 AuronDateFunctionsSuite extends DateFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala new file mode 100644 index 000000000..eb2d96a9b --- /dev/null +++ b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala @@ -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 AuronMathFunctionsSuite extends MathFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala new file mode 100644 index 000000000..a50ff3367 --- /dev/null +++ b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala @@ -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 AuronMiscFunctionsSuite extends MiscFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala new file mode 100644 index 000000000..bd621ba17 --- /dev/null +++ b/auron-spark-tests/spark40/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala @@ -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 AuronStringFunctionsSuite extends StringFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark41/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala b/auron-spark-tests/spark41/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala index 052cca5d1..a04eaebe1 100644 --- a/auron-spark-tests/spark41/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala +++ b/auron-spark-tests/spark41/src/test/scala/org/apache/auron/utils/AuronSparkTestSettings.scala @@ -16,7 +16,55 @@ */ package org.apache.auron.utils +import org.apache.spark.sql._ + class AuronSparkTestSettings extends SparkTestSettings { + { + // Use Arrow's unsafe implementation. + System.setProperty("arrow.allocation.manager.type", "Unsafe") + } + + enableSuite[AuronDataFrameFunctionsSuite] + // Native execution wraps SparkRuntimeException from validation failures in SparkException. + .exclude("map with arrays") + .exclude("map_concat function") + .exclude("SPARK-24734: Fix containsNull of Concat for array type") + .exclude("array_insert functions") + .exclude("transform keys function - Invalid lambda functions and exceptions") + // Native reverse only supports string inputs; array inputs fail with unsupported List type. + .exclude("reverse function - array for primitive type not containing null") + .exclude("reverse function - array for primitive type containing null") + .exclude("reverse function - array for non-primitive type") + // Native flatten can panic when child arrays have different containsNull metadata. + .exclude("flatten function") + + enableSuite[AuronDateFunctionsSuite] + // Native execution wraps Spark parsing/format validation exceptions in SparkException. + .exclude("function to_date") + .exclude("unix_timestamp") + .exclude("to_unix_timestamp") + // Native date_trunc does not support all Spark aliases such as "yy". + .exclude("function date_trunc") + // Native date_trunc throws for unsupported fields instead of returning NULL as Spark does. + .exclude("unsupported fmt fields for trunc/date_trunc results null") + // Native date_trunc may produce incorrect results for historical timestamps with + // non-UTC timezones due to timezone handling differences in the DataFusion engine. + .exclude("SPARK-30766: date_trunc of old timestamps to hours and days") + + enableSuite[AuronMathFunctionsSuite] + // Native acosh uses a different floating-point formula than Spark's StrictMath.log, + // producing results that differ at the last ULP for certain edge-case inputs. + .exclude("acosh") + + enableSuite[AuronMiscFunctionsSuite] + + enableSuite[AuronStringFunctionsSuite] + // Spark 4 adds the threshold argument, but native levenshtein currently supports only + // two arguments. + .exclude("string Levenshtein distance") + // Native substr does not support BinaryType inputs. + .exclude("string / binary substring function") + override def getSQLQueryTestSettings: SQLQueryTestSettings = new SQLQueryTestSettings { override def getResourceFilePath: String = "" override def getSupportedSQLQueryTests: Set[String] = Set.empty diff --git a/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala new file mode 100644 index 000000000..98448e333 --- /dev/null +++ b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDataFrameFunctionsSuite.scala @@ -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 AuronDataFrameFunctionsSuite extends DataFrameFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala new file mode 100644 index 000000000..dddef76fb --- /dev/null +++ b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronDateFunctionsSuite.scala @@ -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 AuronDateFunctionsSuite extends DateFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala new file mode 100644 index 000000000..eb2d96a9b --- /dev/null +++ b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMathFunctionsSuite.scala @@ -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 AuronMathFunctionsSuite extends MathFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala new file mode 100644 index 000000000..a50ff3367 --- /dev/null +++ b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronMiscFunctionsSuite.scala @@ -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 AuronMiscFunctionsSuite extends MiscFunctionsSuite with SparkQueryTestsBase {} diff --git a/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala new file mode 100644 index 000000000..bd621ba17 --- /dev/null +++ b/auron-spark-tests/spark41/src/test/scala/org/apache/spark/sql/AuronStringFunctionsSuite.scala @@ -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 AuronStringFunctionsSuite extends StringFunctionsSuite with SparkQueryTestsBase {} From 969e7bac936d47e8e8743f339e43c7a94363368b Mon Sep 17 00:00:00 2001 From: lyne7-sc <734432041@qq.com> Date: Sat, 9 May 2026 11:04:05 +0800 Subject: [PATCH 3/3] apply format --- .../apache/spark/sql/SparkExpressionTestsBase.scala | 6 ++++-- .../org/apache/spark/sql/SparkQueryTestsBase.scala | 12 ++++++------ .../org/apache/spark/sql/auron/AuronConverters.scala | 6 +++--- .../spark/sql/auron/AuronSparkSessionExtension.scala | 2 +- .../org/apache/spark/sql/auron/NativeHelper.scala | 2 +- .../spark/sql/auron/util/TaskContextHelper.scala | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala index 8a6750f5e..041607656 100644 --- a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala +++ b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkExpressionTestsBase.scala @@ -23,7 +23,6 @@ import scala.collection.mutable.ArrayBuffer import org.apache.commons.io.FileUtils import org.apache.commons.math3.util.Precision -import org.apache.auron.sparkver import org.apache.spark.SparkFunSuite import org.apache.spark.sql.catalyst.{CatalystTypeConverters, InternalRow} import org.apache.spark.sql.catalyst.analysis.ResolveTimeZone @@ -36,6 +35,8 @@ import org.apache.spark.sql.types._ import org.apache.spark.unsafe.types.UTF8String import org.scalactic.TripleEqualsSupport.Spread +import org.apache.auron.sparkver + /** * Base trait for all Spark expression tests. */ @@ -372,7 +373,8 @@ trait SparkExpressionTestsBase private def internalCreateDataFrame( rows: org.apache.spark.rdd.RDD[InternalRow], schema: StructType): org.apache.spark.sql.classic.DataFrame = { - _spark.asInstanceOf[org.apache.spark.sql.classic.SparkSession] + _spark + .asInstanceOf[org.apache.spark.sql.classic.SparkSession] .internalCreateDataFrame(rows, schema) } } diff --git a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala index e99146ed1..8b3db0256 100644 --- a/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala +++ b/auron-spark-tests/common/src/test/scala/org/apache/spark/sql/SparkQueryTestsBase.scala @@ -176,12 +176,12 @@ object AuronQueryTestUtil extends Assertions { s""" |== Results == |${sideBySide( - s"== Correct Answer - ${expectedAnswer.size} ==" +: - getRowType(expectedAnswer.headOption) +: - prepareAnswer(expectedAnswer, isSorted).map(_.toString()), - s"== Auron Answer - ${sparkAnswer.size} ==" +: - getRowType(sparkAnswer.headOption) +: - prepareAnswer(sparkAnswer, isSorted).map(_.toString())).mkString("\n")} + s"== Correct Answer - ${expectedAnswer.size} ==" +: + getRowType(expectedAnswer.headOption) +: + prepareAnswer(expectedAnswer, isSorted).map(_.toString()), + s"== Auron Answer - ${sparkAnswer.size} ==" +: + getRowType(sparkAnswer.headOption) +: + prepareAnswer(sparkAnswer, isSorted).map(_.toString())).mkString("\n")} """.stripMargin } diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala index cfdf4f86c..cc12a176a 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronConverters.scala @@ -429,7 +429,7 @@ object AuronConverters extends Logging { assert( !exec.requiredSchema.exists(e => existTimestampType(e.dataType)), s"Parquet scan with timestamp type is not supported for table: ${tableIdentifier - .getOrElse("unknown")}. " + + .getOrElse("unknown")}. " + "Set spark.auron.enable.scan.parquet.timestamp=true to enable timestamp support " + "or remove timestamp columns from the query.") } @@ -440,7 +440,7 @@ object AuronConverters extends Logging { assert( !exec.requiredSchema.exists(e => existTimestampType(e.dataType)), s"ORC scan with timestamp type is not supported for tableIdentifier: ${tableIdentifier - .getOrElse("unknown")}. " + + .getOrElse("unknown")}. " + "Set spark.auron.enable.scan.orc.timestamp=true to enable timestamp support " + "or remove timestamp columns from the query.") } @@ -448,7 +448,7 @@ object AuronConverters extends Logging { case p => throw new NotImplementedError( s"Cannot convert FileSourceScanExec tableIdentifier: ${tableIdentifier.getOrElse( - "unknown")}, class: ${p.getClass.getName}") + "unknown")}, class: ${p.getClass.getName}") } } diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala index 47492aa3d..b68b04954 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/AuronSparkSessionExtension.scala @@ -91,7 +91,7 @@ case class AuronColumnarOverrides(sparkSession: SparkSession) extends ColumnarRu dumpSimpleSparkPlanTreeNode(sparkPlanTransformed) logInfo(s"Transformed spark plan after preColumnarTransitions:\n${sparkPlanTransformed - .treeString(verbose = true, addSuffix = true)}") + .treeString(verbose = true, addSuffix = true)}") // post-transform Shims.get.postTransform(sparkPlanTransformed, sparkSession.sparkContext) diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala index 7a1e34724..e16656471 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeHelper.scala @@ -74,7 +74,7 @@ object NativeHelper extends Logging { val heapMemory = Runtime.getRuntime.maxMemory() val offheapMemory = totalMemory - heapMemory logWarning(s"memory total: ${Utils.bytesToString(totalMemory)}, onheap: ${Utils.bytesToString( - heapMemory)}, offheap: ${Utils.bytesToString(offheapMemory)}") + heapMemory)}, offheap: ${Utils.bytesToString(offheapMemory)}") offheapMemory } diff --git a/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala b/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala index 37d012cc7..309139ebf 100644 --- a/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala +++ b/spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala @@ -47,7 +47,7 @@ object TaskContextHelper extends Logging { val thread = Thread.currentThread() val threadPrefix = if (context != null) { s"auron native task ${context.partitionId()}.${context.attemptNumber()} in stage ${context - .stageId()}.${context.stageAttemptNumber()} (TID ${context.taskAttemptId()})" + .stageId()}.${context.stageAttemptNumber()} (TID ${context.taskAttemptId()})" } else { "auron native task" }