HI @Johan Van Noten​ 

In the instance that i had which was quite simple it did perform ok, but you are right, about performance, this is something that needs to be monitored. I am sure SQL server would go crazy with this approach.

Thanks

Raghu

Own
Contributor

Iav's solution works.​

Own
Contributor

In case of Azure Databricks you can leverage ADF and run this function using SQL Integration runtime while ingesting without having any dependency on lower SQL environment.

Johan_Van_Noten
New Contributor III

Thanks guys,

@Lav Chandaria​ and @Raghu Bindinganavale​ 's solutions both work, but as indicated in my reply above, I'm worried about the performance of evaluating the datediff (Lav) or the label (Raghu) over the full dataset without the engine being able to just cut away "half" of the potential outcomes based on the single < and information from an index / partition. (see my comment above to Raghu).

I'll try it on a significant dataset once I get the opportunity.

Johan

creastysomp
New Contributor II

Thanks for your suggestion. The fact that I want to do this in SparkSQL is because there is no underlying SQLServer.