Stop select from renaming object

When using select on an object it seems to sometimes be renamed to struct.


input(relation: 'Roads_geopackage', name: 'exposure') as exposures_input
 -> select({*})
 -> select({orig_geom: exposure.geom, exposure: layer_intersection(exposure, bookmark('Stop_Banks_merged'), {SB_Protection: 'stb_height'}, true)})
 -> unnest(exposure, 'segmentID') 
# -> select({{exposure.*, segmentID}})
 -> select({{exposure.geom}})

runs but gives incorrect results. If I include the select on line 5 then it gives the error

      - Could not find 'exposure.geom' among [struct.geom, struct.fid_1, struct.road_name, struct.road_surfa, struct.road_class, struct.SH_ID, struct.UID, struct.road_lanes, struct.roadtype_f, struct.roadtype_s, struct.roadtype_t, struct.roadtype_b, struct.TA_name, struct.nzta_heavy, struct.nzta_hea_1, struct.nzta_onrc, struct.nzta_surfa, struct.nzta_traff, struct.ntza_width, struct.nzta_id, struct.island, struct.mp_dist, struct.road_width, struct.BUFF_DIST, struct.ORIG_FID, struct.SH_Flag, struct.SB_Protection, struct.segmentID]

suggesting -> select({{exposure.*, segmentID}}) has renamed exposure to struct.

How can I either stop the select step from renaming it or how can I re-rename it?

Kia ora John,

When you don’t specify a name for a struct or attribute, RiskScape will assign it a default name (‘struct’ in this case, because it’s defining a struct).

So to fix it in this case, you would do something like this to name the new struct ‘exposure’:

select({ {exposure.*, segmentID} as exposure })

This is an alternative way of specifying a struct’s name (although there are some quirks around only one approach working in particular cases).

select({ exposure: {exposure.*, segmentID} })