KacperG
New Contributor III

Well, in the end, it was caused by skewed data. Document_ID was -1 for returns in sales, so a big part of the table was filled with -1 values. Adding an extra column to the merger solved the problem.

This article helped me a lot: 

https://www.databricks.com/discover/pages/optimize-data-workloads-guide#data-skewness

View solution in original post