You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@auron.apache.org by "robreeves (via GitHub)" <gi...@apache.org> on 2026/05/02 04:18:54 UTC

Re: [PR] [AURON #1891] Implement randn() function [auron]

robreeves commented on code in PR #1938:
URL: https://github.com/apache/auron/pull/1938#discussion_r3176090921


##########
spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala:
##########
@@ -849,6 +849,15 @@ object NativeConverters extends Logging {
       case e: Hex => buildScalarFunction(pb.ScalarFunction.Hex, e.children, e.dataType)
       case e: IsNaN =>
         buildExtScalarFunction("Spark_IsNaN", e.children, e.dataType)
+      case e: Randn =>
+        val seed = e.child match {
+          case Literal(s: Long, _) => s
+          case Literal(s: Int, _) => s.toLong
+          case _ => 0L
+        }
+        buildExprNode {
+          _.setSparkRandnExpr(pb.SparkRandnExprNode.newBuilder().setSeed(seed))
+        }

Review Comment:
   Updated to handle foldable seed expressions and fall back to Spark when the seed can't be resolved.



##########
spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronFunctionSuite.scala:
##########
@@ -650,4 +650,23 @@ class AuronFunctionSuite extends AuronQueryTest with BaseAuronSQLSuite {
       }
     }
   }
+
+  test("randn function with seed") {
+    withTable("t1") {
+      sql("CREATE TABLE t1(id INT) USING parquet")
+      sql("INSERT INTO t1 VALUES(1), (2), (3)")
+
+      // Test randn with different seeds - should produce reproducible results
+      val query =
+        """
+          |SELECT
+          |  id,
+          |  randn(42) AS randn_seed_42,
+          |  randn(100) AS randn_seed_100
+          |FROM t1
+          |""".stripMargin
+
+      checkSparkAnswerAndOperator(query)

Review Comment:
   Added a test for randn(cast(42 as bigint)).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@auron.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org