3 ms·
> For instance, a multi-step funnel, segmented on a couple of columns, would extend to several screenfuls of complex SQL, which is cumbersome to write and diffi
by shubhamjain 11y ago
> For instance, a multi-step funnel, segmented on a couple of columns, would extend to several screenfuls of complex SQL, which is cumbersome to write and difficult to reason about.
The only thing I loathe about SQL is its lack of re-usability. It is hard to write reusable parts and pass them around in functions. Need ten filters which you may / may not use? Write ten queries!
Thankfully, the problem is solved by ORMs ( SQLAlchemy, in my case ). Certainly, in many cases, the mental mapping of map, filter and reduce makes more sense but in the most, I have been more comfortable with using a powerful ORM layer and SQL.
- batbomb 11y agoViews and WITH statements help out quite a bit for this, though it does depend on the database. In general, basic views are well-supported across all RDBMS. If your database supports it, Materialized Views are amazing for the caching of certain complex queries and reusability, and that's something SQLAlchemy can't do by itself.
- cheez 11y agoReusable queries = views
- dwmintz 11y agoTotally agree and the "write-only" nature of SQL is something that makes me crazy. Sounds like you're more of a dev. I'm an analyst, but same problem. For any analytic SQL I wrote more than a couple weeks ago, I end up throwing it out and starting from scratch because it's so hard to understand anything I wrote. ORMs were a huge step forward for devs, but there wasn't really anything similar for analysts. Looker (where I now work after three years as a customer) is, in many ways, the equivalent of an ORM for analytics.