Ask HN: How do you test SQL?
663 pointsI've been looking for resources for our data team to apply best practices for testing SQL pipelines (we use DBT) but have not found anything. How do you test SQL pipelines? What patterns, tools and best practices would you recommend? Any good reference material you know of?
Comments (315) 98 threads
Show all comments
Showing thread 20 of 98
DBT, specifically, DBT-2 is a suit of tests designed to benchmark a database system. These tests aren't interested in, eg. correctness of an application that is using the database. They are meant to be testing the system as a whole by modeling some sort of an "average business" and defining some sort of an "average business operation" and estimating how many of such operations can a particular deployment of a system perform.
Such tests are rarely of any interest to application developer, and are more geared towards DBAs who execute such tests to estimate the efficiency of a system they deploy or to estimate the amount of hardware necessary to support a business.
MySQL DBT2 suit: https://dev.mysql.com/downloads/benchmarks.html
PostgreSQL DBT2 suit: https://wiki.postgresql.org/wiki/DBT-2
Those tools are typically modeled on TPC-B... And, it would require a separate discussion to describe why these tests are obsolete and why there isn't really any replacement.
----
However, from the rest of your question it seems that you may use DBT acronym in some other way... So, what exactly are you testing? Are you interested in performance? A benchmark? Schema correctness? Are you perhaps trying to simply test the application that is using a SQL database and you want to avoid dealing with the database setup as much as possible?
https://www.getdbt.com/
Well... I don't know anything about this tool, but from cursory reading, this is the correctness kind of testing that is meant to examine whether the way you defined the schema actually leads to the results you expect in the data. Well... it's not an interesting kind of testing, at least not for me. So, I don't know much about it. Also, while, obviously, I'm not familiar with this newer tool, I wouldn't trust much someone who reused the name of an existing tool to do something completely unrelated in the same domain. It just feels like these people don't have a very good familiarity with the subject because they caused this confusion.
Actually happened to me twice (different distros at different times did include Docker, the container management tool as "docker" while more commonly naming it something else, like "docker-engine").
As for dbt. I mean... imagine you are selecting the name for your company, that's in SQL business, and you don't even bother to type into your favorite Web search engine "dbt sql"... I mean, it's definitely a business about DataBases, so, certainly a 3-letter acronym with "D" and "B" in it in that order would be truly unique, right?
I'd bet is that what happened is that these people, just like you, thought "I don't know what that is, so it must be unimportant", and they never stopped to consider that they might not know something important about the field they are in.