Improve query data format when not using the flat option