Wrap model selection in sub-select to handle WHERE clauses#103
Conversation
WHERE clauses
1.0.9 status updateWe've spent time evaluating this PR for inclusion in the 1.0.9 release and concluded the unconditional subquery wrap creates a real risk of query-plan regression on enforcing databases (Postgres, Oracle, SQL Server) that we don't want to ship without benchmarks. The 1.0.9 release plan is therefore:
Plan for this PR (#103) - moved to the 1.0.10 milestone:
What we will NOT do:
If you want to drive this forward, the conditional-wrap fallback is straightforward: {%- set has_where = model.config.get('where') %}
{%- if has_where %}
from (select * from {{ model }}) as fk_child_inner
{%- else %}
from {{ model }} fk_child_inner
{%- endif %}This adds zero perf cost in the 99% case (no where clause) while preserving the correctness fix for the 1% with one. We'd be happy to land that variation if you'd prefer. Thanks @sti0 for the original report and patch. The bug is real (#119, #100, #98 all duplicate it) - we just want to make sure the fix doesn't trade one problem for another. |
fixes
Example: