Open radeusgd opened 6 days ago
I've encountered this issue when debugging why Snowflake batching does not improve performance.
Apparently, our SQL_Type_Reference.to_type_override
function that was supposed to avoid triggering the lazy computation, was actually triggering it due to this problem.
Marking as lowest priority since an easy workaround exists - as demonstrated by tricky_get_if_eager
.
The workaround is slightly annoying, but usable.
Let me show this on example:
The current behaviour is as follows:
As we can see both
v1
andv2
are computed. I think this is wrong.Ideally, neither of them should be computed as we don't use either value.
It seems acceptable to compute
v2
as we are binding the value tox
so it seems OK to force it to compute. However ideally, the variablex
could 'inherit' the laziness and only be computed if it is actually demanded (as if it were an~suspended
argument). It could possibly be marked by usingMy_Ref.Lazy ~x -> ...
in the pattern match. Currently I have checked and adding the~
tox
and_
does not change the behaviour.However, for
_
it should really be noted to not be computed as we explicitly ignore the value. This makes decomposing a value without triggering execution quite hard - as shown intricky_get_if_eager
- the only variant that currently works as desired.