A nice analysis, and it shows how SQL makes it easy to quickly explore data.
However, it seems like the plots of the results of the queries were done manually by writing some code to make each plot.
I can't stop but mention that using Apache Zeppelin Notebook [1] with Postgres interpreter for Zeppelin [2] (Spark SQL should provide comparable analytical capabilities as well, but this comment is not about it) it is possible to show graphical representation of query results without writing a single line of code.
[1] https://zeppelin.apache.org/
[2] https://zeppelin.apache.org/docs/latest/interpreter/postgres...