Precedence of set operations
Set operations are executed by priority instead having equal precedence.
Type of change: Property/Spark SQL changes
Spark 1.6 - 2.3
If the order is not specified by parentheses, equal precedence is given to all set operations.
Spark 2.4
If the order is not specified by parentheses, set operations are performed from left to right with the exception that all INTERSECT operations are performed before any UNION, EXCEPT or MINUS operations.
For example, if your code includes set operations, such as INTERSECT , UNION, EXCEPT or MINUS, consider refactoring.
Action Required
Change the logic according to following rule:
If the order of set operations is not specified by parentheses, set operations are performed from left to right with the exception that all INTERSECT operations are performed before any UNION, EXCEPT or MINUS operations.
If you want the previous behavior of equal precedence then, set
spark.sql.legacy.setopsPrecedence.enabled=true
.