Below is an example of the auto-generated update query, with client-supplied keys (_iid). There's a fatal error when _iid is not numeric. However; this should accept any value.
The supplied query is not an update query and as far as I can tell nothing in it compels the system to try and convert your text _iid from the CTE to an integer. So, you are still not showing us the whole picture. But, if whatever target relation you are trying to insert/update this record against defines _iid as integer then you need to change it to be defined as text.