title: Expressing complex logic in case statements in dbt using a lookup table
body: <p>I'm reworking a good part of our Analytics Data Warehouse and am trying to build things out in a much more modular way. We've swapped to DBT vs an in house transformation tool and I'm trying to take advantage of the functionality it offers.</p>
  <p>Previously, the way we classified our rental segments was in a series of CASE statements which evaluate a few fields. These are (sudocode)</p>
  <pre><code>CASE WHEN rental_rule_type &lt;&gt; monthly 
  AND rental_length BETWEEN 6 AND 24
  AND rental_day IN (0,1,2,3,4)
  AND rental_starts IN (5,6,7,8,9,10,11)
  THEN weekday_daytime_rental
  </code></pre>
  <p>This obviously works. But it's ugly and hard to update. If we want to adjust this, we'll need to do so in the SQL rather than in a lookup table.</p>
  <p>What I'd like to build is a simple lookup table that holds these values that can be adjusted at a later date to easily adjust how we classify these rentals, but I'm not sure what the best approach is.</p>
  <p>My current thought is to layer these conditions into an excel file, load it into the warehouse with DBT and then join on these conditions, however I'm not sure if that would end up being cleaner logic or not. It would mean there are no hardcoded values in the code, but it would likely still result in a ton of ugly cases and joins.</p>
  <p>I think there are some global variables I could define as well in DBT which may help with this?</p>
  <p>Anyone approach something similar? Would love to hear some best practices.</p>