|
|
|
|
|
by KronisLV
1751 days ago
|
|
That's indeed a useful trick, but wouldn't it be better to be able to execute pieces of SQL without altering the actual code? For example, selecting the CTEs up to a certain point and using a particular button or keyboard shortcut within a development tool, much like we can already do with executing selection? Of course, adding "clever" functionality like that might as well create some risks and inconsistencies, so i'm not entirely sure about that. |
|
This is an entirely different subject and deserves a long discussion, and one which SQL is not ideal for.
As you said, breaking CTEs into separate views is the start, and then you can use a tool like getdbt.com to make your references into parameters. And then you also need to create the mock data (which you can do for example by writing it into csv:s)
From the role of an analyst I must say though, that once you have done all that work, the risk is that you forgot to worry about to the biggest risk here. What is actually inside that data you are querying? Maybe your biggest problem is not the logic of the query, but rather how dirty your input data is? Or for that matter, that you made completely incorrect assumptions on your input data, like that column X contains distinct values when it contains duplicates. That type of error wreaks havoc on your end result, with a big chance you'll never notice.