Fix bug in check if materialization should be run.