@@ -227,20 +227,24 @@ class ColumnExpressionSuite extends QueryTest with SQLTestUtils {
227227
228228 test(" nanvl" ) {
229229 val testData = ctx.createDataFrame(ctx.sparkContext.parallelize(
230- Row (null , 3.0 , Double .NaN , Double .PositiveInfinity ) :: Nil ),
230+ Row (null , 3.0 , Double .NaN , Double .PositiveInfinity , 1.0f , 4 ) :: Nil ),
231231 StructType (Seq (StructField (" a" , DoubleType ), StructField (" b" , DoubleType ),
232- StructField (" c" , DoubleType ), StructField (" d" , DoubleType ))))
232+ StructField (" c" , DoubleType ), StructField (" d" , DoubleType ),
233+ StructField (" e" , FloatType ), StructField (" f" , IntegerType ))))
233234
234235 checkAnswer(
235236 testData.select(
236- nanvl($" a" , lit(5 )), nanvl($" b" , lit(10 )),
237- nanvl($" c" , lit(null ).cast(DoubleType )), nanvl($" d" , lit(10 ))),
238- Row (null , 3.0 , null , Double .PositiveInfinity )
237+ nanvl($" a" , lit(5 )), nanvl($" b" , lit(10 )), nanvl(lit(10 ), $" b" ),
238+ nanvl($" c" , lit(null ).cast(DoubleType )), nanvl($" d" , lit(10 )),
239+ nanvl($" b" , $" e" ), nanvl($" e" , $" f" )),
240+ Row (null , 3.0 , 10.0 , null , Double .PositiveInfinity , 3.0 , 1.0 )
239241 )
240242 testData.registerTempTable(" t" )
241243 checkAnswer(
242- ctx.sql(" select nanvl(a, 5), nanvl(b, 10), nanvl(c, null), nanvl(d, 10) from t" ),
243- Row (null , 3.0 , null , Double .PositiveInfinity )
244+ ctx.sql(
245+ " select nanvl(a, 5), nanvl(b, 10), nanvl(10, b), nanvl(c, null), nanvl(d, 10), " +
246+ " nanvl(b, e), nanvl(e, f) from t" ),
247+ Row (null , 3.0 , 10.0 , null , Double .PositiveInfinity , 3.0 , 1.0 )
244248 )
245249 }
246250
0 commit comments