Ian Koh
09/24/2024, 12:38 PMCASE WHEN
syntax in SQL)
Example syntax
val df2: DataFrame<*> = df1
.add("derivedCol") {
when {
colA == 0 -> "NewValueA"
colB == 0 -> "NewValueB"
else -> "Error"
}
}
.remove { colA and colB }
In Kotlin Notebook
• Both colA
and colB
are marked with an 'Unresolved reference' error
• However, the dataframe df2
is still created without issue, and I can manipulate and work with it in subsequent cells (along with the new column derivedCol
)
• The code in the notebook is for prototyping; once ready, it will be transferred to a Kotlin file
In source code
• I am running the same code as I've done in the notebook above
• The same error is being shown for colA
and colB
• Now, however, I am unable to build my code
My questions
• How does one make a dataframe's column recognisable to the Kotlin compiler?
• Why did it work in the Kotlin notebook but not in my Kotlin file?Jolan Rensen [JB]
09/25/2024, 8:21 AMIan Koh
09/26/2024, 11:42 AM