I have a dataframe df. In which we have order_date I need to scan through the years from the date column (using split) and compare it to end year if it matches then assign it to @i and then increase the end year I have added a df to show the putput expected
df:
df[order_date] = 1/2/2020
df[st_yr] = 2020
df[ed_yr] = df[st_yr] + 1
do i = 1 to 5
if df.withColumn("order_date", split(col("order_date"), "/").getItem(2)) = df[ed_yr]
df[st_yr] = i;
df[ed_yr] = df[ed_yr] + 1
end