dtenedor commented on code in PR #41486:
URL: https://github.com/apache/spark/pull/41486#discussion_r1240463321


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datasketchesExpressions.scala:
##########
@@ -98,15 +104,22 @@ case class HllUnion(first: Expression, second: Expression, 
third: Expression)
   override def dataType: DataType = BinaryType
 
   override def nullSafeEval(value1: Any, value2: Any, value3: Any): Any = {
-    val sketch1 = 
HllSketch.heapify(Memory.wrap(value1.asInstanceOf[Array[Byte]]))
-    val sketch2 = 
HllSketch.heapify(Memory.wrap(value2.asInstanceOf[Array[Byte]]))
+    val sketch1 = try {
+      HllSketch.heapify(Memory.wrap(value1.asInstanceOf[Array[Byte]]))
+    } catch {
+      case _: java.lang.Error =>
+        throw QueryExecutionErrors.hllInvalidInputSketchBuffer(prettyName)
+    }
+    val sketch2 = try {
+      HllSketch.heapify(Memory.wrap(value2.asInstanceOf[Array[Byte]]))
+    } catch {
+      case _: java.lang.Error =>
+        throw QueryExecutionErrors.hllInvalidInputSketchBuffer(prettyName)
+    }
     val allowDifferentLgConfigK = value3.asInstanceOf[Boolean]
     if (!allowDifferentLgConfigK && sketch1.getLgConfigK != 
sketch2.getLgConfigK) {
-      throw new UnsupportedOperationException(
-        "Sketches have different lgConfigK values: " +
-        s"${sketch1.getLgConfigK} and ${sketch2.getLgConfigK}. " +
-        "Set allowDifferentLgConfigK to true to enable unions of " +
-        "different lgConfigK values.")
+      throw QueryExecutionErrors.hllUnionDifferentLgK(
+        sketch1.getLgConfigK, sketch2.getLgConfigK, function = "HLL_UNION")

Review Comment:
   No worries, fixed!



-- 
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: reviews-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to