File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
sql/core/src/test/scala/org/apache/spark/sql Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -2864,21 +2864,24 @@ class DataFrameSuite extends QueryTest
28642864
28652865 test(" SPARK-35410: SubExpr elimination should not include redundant child exprs " +
28662866 " for conditional expressions" ) {
2867- val myUdf = udf((s : String ) => {
2868- KeepCall .countOfCalls += 1
2867+ val accum = sparkContext.longAccumulator(" call" )
2868+ val simpleUDF = udf((s : String ) => {
2869+ accum.add(1 )
28692870 s
28702871 })
2871- val df = spark.range(5 ).select(when(functions.length(myUdf($" id" )) > 0 ,
2872- functions.length(myUdf($" id" ))))
2873- df.collect()
2874- assert(KeepCall .countOfCalls == 5 )
2872+ val df1 = spark.range(5 ).select(when(functions.length(simpleUDF($" id" )) > 0 ,
2873+ functions.length(simpleUDF($" id" ))))
2874+ df1.collect()
2875+ assert(accum.value == 5 )
2876+
2877+ val nondeterministicUDF = simpleUDF.asNondeterministic()
2878+ val df2 = spark.range(5 ).select(when(functions.length(nondeterministicUDF($" id" )) > 0 ,
2879+ functions.length(nondeterministicUDF($" id" ))))
2880+ df2.collect()
2881+ assert(accum.value == 15 )
28752882 }
28762883}
28772884
28782885case class GroupByKey (a : Int , b : Int )
28792886
28802887case class Bar2 (s : String )
2881-
2882- object KeepCall {
2883- var countOfCalls = 0
2884- }
You can’t perform that action at this time.
0 commit comments