Closed rcauble closed 11 months ago
This is a fantastic discovery.
Currently, when deciding whether to use CTEs (Common Table Expressions), we do not take into account whether non-deterministic functions are present within the operators. This can result in unexpected outcomes.
set cbo_cte_reuse_rate=0
to enforce cte for reuse to avoid this bug.
Steps to reproduce the behavior (Required)
Expected behavior (Required)
If you diff correct.sql and bug.sql, you can see that there's a small change that should not affect the results. I expect the to SQLs to produce equivalent results:
Real behavior (Required)
They produce different results. My guess is that the UUID is getting inlined somewhere and causing it to produce different UUIDs for the same CTE and thus we are not joining as we expect to.
StarRocks version (Required)
starrocks/allin1-ubuntu:3.1.0-rc01