Fix row number optimizations for unreferenced outputs
Fix failure when output of UNNEST is not used