If 30% of a billion-record dataset contains duplicate transaction IDs, how would you efficiently identify the most frequent duplicates and optimize the Spark job?
Asked in the R2 PySpark stage. Write a Python function that takes a list of transaction IDs and returns the IDs with the highest duplicate counts, sorted by count descending then ID ascending.
transaction_ids: list of strings or integersdef most_frequent_duplicates(transaction_ids):