Skip to content
Open
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 @@ -33,11 +33,16 @@ class AuronExpressionSuite extends AuronQueryTest with BaseAuronSQLSuite {
}

test("UnaryMinus") {
withTable("t1") {
sql("create table t1(col1 int) using parquet")
sql(
"insert into t1 values(1), (2), (3), (3), (-1), (0), (null), (2147483647), (-2147483648)")
checkSparkAnswerAndOperator("SELECT negative(col1), -(col1) FROM t1")
// Negating Int.MinValue overflows. Under ANSI mode (default in Spark 4.x) vanilla Spark
// throws while the native engine wraps, so the comparison diverges. Disable ANSI so both
// engines wrap consistently and the boundary value can still be exercised.
withSQLConf("spark.sql.ansi.enabled" -> "false") {
withTable("t1") {
sql("create table t1(col1 int) using parquet")
sql(
"insert into t1 values(1), (2), (3), (3), (-1), (0), (null), (2147483647), (-2147483648)")
checkSparkAnswerAndOperator("SELECT negative(col1), -(col1) FROM t1")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,17 @@ class AuronFunctionSuite extends AuronQueryTest with BaseAuronSQLSuite {
test("acosh null propagation") {
withTable("t1") {
sql("create table t1(c1 double) using parquet")
sql("insert into t1 values(null), (0.0), (1.0), (2.0)")
sql("insert into t1 values(null), (1.0), (2.0)")
checkSparkAnswerAndOperator("select acosh(c1) from t1")
}
withTable("t2") {
sql("create table t2(c1 double) using parquet")
sql("insert into t2 values(0.0), (-1.0)")
// acosh is defined on [1, inf), so out-of-domain inputs yield NaN. Vanilla Spark and the
// native engine may encode that NaN with different bits (checkSparkAnswerAndOperator
// compares doubles by raw bits), so compare NaN-ness via the natively-supported isnan.
checkSparkAnswerAndOperator("select isnan(acosh(c1)) from t2")
Comment thread
robreeves marked this conversation as resolved.
}
}

test("test function least") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ import org.apache.auron.util.AuronTestUtils
class AuronQuerySuite extends AuronQueryTest with BaseAuronSQLSuite with AuronSQLTestHelper {
import testImplicits._

test("config alt keys are honored") {
// AURON_ENABLED has primary key "spark.auron.enabled" and alt key "spark.auron.enable".
// Setting either key must take effect (primary takes precedence over alt).
withSQLConf("spark.auron.enabled" -> "false") {
assert(!SparkAuronConfiguration.AURON_ENABLED.get())
}
withSQLConf("spark.auron.enable" -> "false") {
assert(!SparkAuronConfiguration.AURON_ENABLED.get())
}
withSQLConf("spark.auron.enabled" -> "true") {
assert(SparkAuronConfiguration.AURON_ENABLED.get())
}
withSQLConf("spark.auron.enable" -> "true") {
assert(SparkAuronConfiguration.AURON_ENABLED.get())
}
// Primary key wins when both are set to conflicting values.
withSQLConf("spark.auron.enabled" -> "true", "spark.auron.enable" -> "false") {
assert(SparkAuronConfiguration.AURON_ENABLED.get())
}
}

test("test partition path has url encoded character") {
withTable("t1") {
sql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.spark.internal.config.ConfigEntryWithDefaultFunction;
import org.apache.spark.sql.internal.SQLConf;
import scala.Option;
import scala.collection.immutable.List$;
import scala.collection.mutable.ListBuffer;

/**
* Spark configuration proxy for Auron.
Expand Down Expand Up @@ -561,21 +561,23 @@ private <T> T getFromSpark(

synchronized (SparkAuronConfiguration.class) {
String sparkConfKey = key.startsWith(SPARK_PREFIX) ? key : SPARK_PREFIX + key;
ListBuffer<String> sparkConfAltKeys = new ListBuffer<>();

configEntry = ConfigEntry.findEntry(sparkConfKey);
for (String altKey : altKeys) {
String sparkConfAltKey = altKey.startsWith(SPARK_PREFIX) ? altKey : SPARK_PREFIX + altKey;
if (configEntry != null) {
break;
sparkConfAltKeys.$plus$eq(sparkConfAltKey);
if (configEntry == null) {
configEntry = ConfigEntry.findEntry(sparkConfAltKey);
}
configEntry = ConfigEntry.findEntry(sparkConfAltKey);
}

if (configEntry == null) {
configEntry = new ConfigEntryWithDefaultFunction<>(
sparkConfKey,
Option.empty(),
"",
List$.MODULE$.empty(),
sparkConfAltKeys.toList(),
defaultValueSupplier::get,
val -> valueConverter(val, valueClass),
String::valueOf,
Expand Down
Loading