How many rows are you expecting from the output of this query? Beeline client in its default setting is prone to memory issues when large number of rows get fetched as it buffers all rows in memory. The workaround is to use the following argument when starting beeline.
HIVE-7224 which was recently fixed will make that setting as default but for now you will need to use the above argument to beeline client. More documentation on that option and others is on Hive Wiki.