Fixed #22847: Optimizer wasn't expecting unresolved FKs