jiangxt2 commented on code in PR #58117:
URL: https://github.com/apache/spark/pull/58117#discussion_r4431742462


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala:
##########
@@ -182,7 +182,8 @@ trait InvokeLike extends Expression with NonSQLExpression 
with ImplicitCastInput
     var i = 0
     val len = arguments.length
     var resultNull = false
-    while (i < len) {
+    // Short-circuit after a result-determining null to match prepareArguments.
+    while (i < len && !resultNull) {

Review Comment:
   Fixed in `69967924ed8`. Both `InvokeLike.invoke` and `NewInstance.eval` 
clear the remaining `evaluatedArgs` slots before returning NULL, without 
evaluating skipped expressions. Added reference checks for `StaticInvoke`, 
`Invoke`, and `NewInstance` across a normal row, a NULL short-circuit row, and 
a subsequent normal row, plus a separate `StaticInvoke` control with 
`propagateNull = false`. `ObjectExpressionsSuite` (30 tests) and `DatasetSuite` 
(222 tests) passed locally.
   



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/bitmapExpressions.scala:
##########
@@ -375,6 +383,83 @@ case class BitmapXor(left: Expression, right: Expression) 
extends BitmapBinaryEx
     copy(left = newLeft, right = newRight)
 }
 
+@ExpressionDescription(
+  usage = """
+    _FUNC_(bitmap, bit_position) - Returns true if the bit at the given 
bucket-local position is
+    set in the bitmap, false otherwise.
+  """,
+  arguments = """
+    Arguments:
+      * bitmap - The bitmap to test.
+        An expression that evaluates to a binary. A NULL bitmap produces a 
NULL result.
+      * bit_position - The bucket-local bit position to test.
+        An expression that evaluates to a numeric value and is cast to a long. 
A NULL position
+        produces a NULL result. A negative position, a position at or above 
32768, or a position
+        beyond the actual bitmap length returns false. To query an original 
value, use
+        bitmap_bit_position(value) and match bitmap_bucket_number(value) to 
the bitmap bucket.
+  """,
+  examples = """
+    Examples:
+      > SELECT _FUNC_(X '01', 0L);
+       true
+      > SELECT _FUNC_(X '01', 1L);
+       false
+      > SELECT _FUNC_(X '10', 4L);
+       true
+  """,
+  since = "4.4.0",
+  group = "misc_funcs")
+case class BitmapContains(left: Expression, right: Expression)
+  extends BinaryExpression with RuntimeReplaceable {
+
+  override def checkInputDataTypes(): TypeCheckResult = {
+    if (left.dataType != BinaryType && left.dataType != NullType) {
+      DataTypeMismatch(
+        errorSubClass = "UNEXPECTED_INPUT_TYPE",
+        messageParameters = Map(
+          "paramIndex" -> ordinalNumber(0),
+          "requiredType" -> toSQLType(BinaryType),
+          "inputSql" -> toSQLExpr(left),
+          "inputType" -> toSQLType(left.dataType)
+        )
+      )
+    } else if (!right.dataType.isInstanceOf[NumericType] && right.dataType != 
NullType) {
+      DataTypeMismatch(
+        errorSubClass = "UNEXPECTED_INPUT_TYPE",
+        messageParameters = Map(
+          "paramIndex" -> ordinalNumber(1),
+          "requiredType" -> toSQLType(LongType),

Review Comment:
   Fixed in `69967924ed8`: the diagnostic now uses `toSQLType(NumericType)` and 
the negative test expects `NUMERIC`. Numeric input acceptance and 
numeric-to-long cast semantics are unchanged. `BitmapExpressionsQuerySuite` 
passed locally.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to