query = [['abcd', 30], ['adab', 34], ['dbab', 38]]
reference = [['dbab', 20], ['ccdd', 24], ['abcd', 50], ['adab', 54], [
    'dbab', 58], ['dbab', 62]]
Spark: More Efficient Aggregation to join strings from different rows