The upgrade from Spark 2 to Spark 3 seems to have changed the pipeline's overall query plan, slowing down the total execution time.
See problem at T323107#8532485.
Possible solution: T323107#8544892
See also https://gitlab.wikimedia.org/repos/structured-data/section-topics/-/merge_requests/8#note_15006.
NOTE: the code base underwent major changes since the Spark upgrade, so the query plan may be different from the one reported in T323107#8532485.