DRILL-1333: Flatten operator

Fixed issue with complex writer after failure due to filled vector, now calling reset function in the generated code before trying to write again.