wangyum commented on a change in pull request #28626:
URL: https://github.com/apache/spark/pull/28626#discussion_r429736166



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/expressions/ExpressionInfoSuite.scala
##########
@@ -156,4 +158,74 @@ class ExpressionInfoSuite extends SparkFunSuite with 
SharedSparkSession {
       }
     }
   }
+
+  test("Check whether should extend NullIntolerant") {
+    // Only check expressions extended from these expressions
+    val parentExpressionNames = Seq(classOf[UnaryExpression], 
classOf[BinaryExpression],
+      classOf[TernaryExpression], classOf[QuaternaryExpression],
+      classOf[SeptenaryExpression]).map(_.getName)
+    // Do not check these expressions
+    val whiteList = Seq(
+      classOf[IntegralDivide], classOf[Divide], classOf[Remainder], 
classOf[Pmod],
+      classOf[CheckOverflow], classOf[NormalizeNaNAndZero], classOf[InSet],
+      classOf[PrintToStderr], 
classOf[CodegenFallbackExpression]).map(_.getName)
+
+    spark.sessionState.functionRegistry.listFunction()
+      .map(spark.sessionState.catalog.lookupFunctionInfo).map(_.getClassName)
+      .filterNot(c => whiteList.exists(_.equals(c))).foreach { className =>
+      if (needToCheckNullIntolerant(className)) {
+        val evalExist = checkIfEvalOverrode(className)
+        val nullIntolerantExist = checkIfNullIntolerantMixedIn(className)
+        if (evalExist && nullIntolerantExist) {
+          fail(s"$className should not extend 
${classOf[NullIntolerant].getSimpleName}")
+        } else if (!evalExist && !nullIntolerantExist) {
+          fail(s"$className should extend 
${classOf[NullIntolerant].getSimpleName}")
+        } else {
+          assert((!evalExist && nullIntolerantExist) || (evalExist && 
!nullIntolerantExist))
+        }
+      }
+    }
+
+    def needToCheckNullIntolerant(className: String): Boolean = {

Review comment:
       Only check expressions extended from these 
expressions(`UnaryExpression`, `BinaryExpression`, `TernaryExpression`, 
`QuaternaryExpression` and `SeptenaryExpression`) because these expressions are 
NullIntolerant by default.




----------------------------------------------------------------
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.

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