How to check if a column in a query can produce NULL?
Since SQL (with recursive CTEs) is Turing complete, figuring out if a column in the result could be NULL or not is probably as complex as the halting problem and cannot be computed.
So either run the query and examine the result or restrict yourself to very simple queries (but even then the problem will be non-trivial).
My personal recommendation is to give up.