@@ -18,6 +18,8 @@ package org.apache.spark.sql.auron
1818
1919import java .text .SimpleDateFormat
2020
21+ import scala .collection .mutable .ArrayBuffer
22+
2123import org .apache .spark .sql .Row
2224import org .apache .spark .sql .execution .adaptive .AdaptiveSparkPlanHelper
2325
@@ -522,18 +524,23 @@ class AuronFunctionSuite
522524
523525 test(" test function nvl2" ) {
524526 withTable(" t1" ) {
525- sql(
526- " create table t1 using parquet as select 'base'" +
527- " as base, 3 as exponent" )
528- val functions =
529- """
530- |select
531- | nvl2(null, base, exponent), nvl2(4, base, exponent)
532- |from t1
533- """ .stripMargin
534-
535- val df = sql(functions)
536- checkAnswer(df, Seq (Row (" base" , 3 )))
527+ sql(s """ CREATE TABLE t1 USING PARQUET AS SELECT
528+ |'X' AS str_val,
529+ |100 AS int_val,
530+ |array(1,2,3) AS arr_val,
531+ |CAST(NULL AS STRING) AS null_str,
532+ |CAST(NULL AS INT) AS null_int
533+ | """ .stripMargin)
534+
535+ val df = sql(s """ SELECT
536+ |nvl2(null_int, int_val, 999) AS int_only,
537+ |nvl2(1, str_val, int_val) AS has_str,
538+ |nvl2(null_int, int_val, str_val) AS str_in_false,
539+ |nvl2(1, arr_val, array(888)) AS has_array,
540+ |nvl2(null_int, null_str, null_str) AS all_null
541+ |FROM t1 """ .stripMargin)
542+
543+ checkAnswer(df, Row (999 , " X" , " X" , ArrayBuffer (1 , 2 , 3 ), null ))
537544 }
538545 }
539546
0 commit comments