I have defined a column StartDate
as follows for a DataFrame I am loading using the dataframe-ec library.
schema.addColumn("StartDate", ValueType.DATE);
I would like to add a computed column named DaysToEvent
but am unsure how to define a function leveraging the Java time library so the following expression code will work.
dataFrame.attachColumn(
dataFrame.createComputedColumn(
"DaysToEvent",
ValueType.LONG,
"daysBetween(toDate(2023, 3, 11), StartDate)"));
I saw there was a built-in function named withinDays
but am hoping to not have to change the library to add this function. I tried defining the expression using Java Code inline but that didn't work.
dataFrame.attachColumn(
dataFrame.createComputedColumn(
"DaysToEvent",
ValueType.LONG,
"java.time.temporal.ChronoUnit.DAYS.between(toDate(2023, 3, 11), StartDate)"));