У меня есть датафрейм, то есть resultDf, как показано ниже
+---------------+-------------------+--------------------+-------------------+-------------------+--------------+-----------------------+----------------------+
|model_family_id|classification_type|classification_value|benchmark_type_code| data_date|data_item_code|data_item_value_numeric|data_item_value_string|
+---------------+-------------------+--------------------+-------------------+-------------------+--------------+-----------------------+----------------------+
| 1| COUNTRY| AGO| MEAN|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| OBS_CNT|2018-03-31 00:00:00| CREDITSCORE| 4| b|
| 1| COUNTRY| AGO| OBS_CNT_CA|2018-03-31 00:00:00| CREDITSCORE| 4| null|
| 1| COUNTRY| AGO| PERCENTILE_0|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| PERCENTILE_10|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| PERCENTILE_100|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| PERCENTILE_25|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| PERCENTILE_50|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| PERCENTILE_75|2018-03-31 00:00:00| CREDITSCORE| 15| b|
| 1| COUNTRY| AGO| PERCENTILE_90|2018-03-31 00:00:00| CREDITSCORE| 15| b|
+---------------+-------------------+--------------------+-------------------+-------------------+--------------+-----------------------+----------------------+
Я поворачиваю таблицу на основе столбца «benchmark_type_code», необходимо реализовать нижеприведенную бизнес-логику
Если (data_item_code) равен «SCORE»"ИЛИ" PG_SCORE "====> выбрать data_item_value_string в качестве значения else ==> выбрать data_item_value_numeric в качестве значения
Для этого я написал ниже код
val pivot_resultDf = resultDf.groupBy("model_family_id","classification_type","classification_value" ,"benchmark_type_code","data_date")
.pivot("benchmark_type_code")
.agg( first(
when( col("data_item_code").===("SCORE"), col("data_item_value_numeric"))
.otherwise(col("data_item_value_string"))
) )
Но я получаюошибка в функции агг @ при условии
java.lang.AssertionError: assertion failed: unsafe symbol Unstable (child of <none>) in runtime reflection universe
at scala.reflect.internal.Symbols$Symbol.<init>(Symbols.scala:205)
at scala.reflect.internal.Symbols$TypeSymbol.<init>(Symbols.scala:3030)
at scala.reflect.internal.Symbols$Symbol.newStubSymbol(Symbols.scala:521)
at scala.reflect.internal.pickling.UnPickler$Scan.readExtSymbol$1(UnPickler.scala:258)
at scala.reflect.internal.pickling.UnPickler$Scan.readSymbol(UnPickler.scala:286)
at scala.reflect.runtime.JavaMirrors$JavaMirror.unpickleClass(JavaMirrors.scala:619)
at scala.reflect.runtime.SymbolLoaders$TopClassCompleter$$anonfun$complete$1.apply$mcV$sp(SymbolLoaders.scala:28)
at scala.reflect.runtime.SymbolLoaders$TopClassCompleter$$anonfun$complete$1.apply(SymbolLoaders.scala:25)
at scala.reflect.runtime.SymbolLoaders$TopClassCompleter$$anonfun$complete$1.apply(SymbolLoaders.scala:25)
at scala.reflect.internal.SymbolTable.slowButSafeEnteringPhaseNotLaterThan(SymbolTable.scala:263)
at scala.reflect.runtime.SymbolLoaders$TopClassCompleter.complete(SymbolLoaders.scala:25)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1535)
at org.apache.spark.sql.catalyst.expressions.Literal$.create(literals.scala:158)
at org.apache.spark.sql.functions$.typedLit(functions.scala:113)
at org.apache.spark.sql.functions$.lit(functions.scala:96)
at org.apache.spark.sql.Column.$eq$eq$eq(Column.scala:262)
Что я здесь не так делаю?как это исправить?