presto-main/src/main/java/io/prestosql/execution/StageInfo.java/StageInfo/isFinalStageInfo
class StageInfo:    public boolean isFinalStageInfo()
    {
        return state.isDone() && tasks.stream().allMatch(taskInfo -> taskInfo.getTaskStatus().getState().isDone());
    }