There are 2 tables, Cars and Cars_Sales
There is sales on Cars every month from the date it is launched
There are some records when Cars Sales information is missing during initial launch
in that case we need to drag the data from latest available sales information till its launch period
Sample data
——–+——+——+———–+———–+
car_code|name |model |launch_date|curr_period|
——–+——+——+———–+———–+
123|Toyota|model1| 202311| 202403|
124|Toyota|model2| 202401| 202403|
Car_Sales Table
——+——–+——+———–+
period|car_code|model |sales_units|
——+——–+——+———–+
202401| 123|model1| 458|
202402| 123|model1| 893|
202402| 124|model2| 834|
202403| 123|model1| 846|
202403| 124|model2| 976|
202401| 124|model2| 585|
——+——–+——+———–+
Expected output
——+——–+——+———–+
period|car_code|model |sales_units|
——+——–+——+———–+
202311| 123|model1| 458| <– Drag record
202312| 123|model1| 458| <– Drag record
202401| 123|model1| 458|
202402| 123|model1| 893|
202403| 123|model1| 846|
202401| 124|model2| 585|
202402| 124|model2| 834|
202403| 124|model2| 976|
——+——–+——+———–+
please suggest any ways to drag to records,
using hive or sprak dataframe