...
IF ftype<20 THEN -- feature_type id
q_ins:= $$
INSERT INTO ingest.cadastral_asis
SELECT file_id, cad_id, properties
FROM scan WHERE properties IS NOT NULL AND cad_id IS NOT NULL
$$;
ELSE
q_ins:= $$
INSERT INTO ingest.feature_asis
SELECT *
FROM scan WHERE geom IS NOT NULL AND ST_IsValid(geom)
$$;
END IF;
Trecho principal de
FUNCTION ingest.any_load()
a ser corrigido