UNION ALL returns zero record with aggregate functions in SELECT statement

This article explains how to solve the issue that UNION ALL returns zero record with aggregate functions in SELECT statement The following is the test case: UNION ALL without COUNT function will work as expected: Run the same query without setting hive.mapred.supports.subdirectories and hive.optimize.union.remove to true will give correct result: …