fix QueryEncoding.plan could be null
Ingesting and unit tests, for example.