You should be using an interface or abstract base to abstract out the differences between a catalog table based implementation and a subquery based implementation, NOT this modal structure where either table or tablederived is null and you need to test which in every call.
Maybe make StmtTableScan the abstract base?