SQL generation and rewriting. Cube.js is a simple yet powerful way to organize SQL queries. The Cube.js way is to generate the best possible SQL query for a given database while abstracting all complex stuff from users and giving them full power of SQL at the same time. To solve this problem, Cube.js parses SQL queries written by users to understand the structure and rewrites them to apply performance optimizations.