KNN join with conditions

Is it possible to perform KNN with conditions (gender == gender) which are present in regular joins? Example:

  1. Row 1: [name=James, gender=male]
  2. Row 2: [name=Andrew, gender=male]
  3. Row 3: [name=Ana, gender=female]
  4. Row 3: [name=Jasmine, gender=female]

I would like KNN to be done between genders, so that only james and andrew are compared and only ana and jasmine are compared. My temporary fix is to have multiple KNN blocks where the data is already segmented before being passed in but this is not scalable.

Hi there! Are you able to create a custom expression for your comparison? You can use a custom expression to compare equality of columns, and then return distance results if the column matches.