from what I understood in your question - your original row is as below
STRUCT(STRUCT(STRUCT(10 AS c,'test' AS d) AS b,'field2' AS field2) AS a) original_struct
and you need to get it to
STRUCT(STRUCT(STRUCT(10 AS c) AS b,'field2' AS field2) AS a) original_struct
Below is for BigQuery Standard SQL for this to accomplish
#standardSQL
WITH t AS (
SELECT STRUCT(STRUCT(STRUCT(10 AS c,'test' AS d) AS b,'field2' AS field2) AS a) original_struct
)
SELECT
original_struct,
(
SELECT AS STRUCT (
SELECT AS STRUCT (
SELECT AS STRUCT * EXCEPT(d)
FROM UNNEST([original_struct.a.b]) b
) b,
original_struct.a.field2
) a
) new_struct
FROM t
original struct look as
Row original_struct.a.b.c original_struct.a.b.d original_struct.a.field2
1 10 test field2
and new struct is
Row new_struct.a.b.c new_struct.a.field2
1 10 field2
So, to further apply this to your particular case - see example below
#standardSQL
WITH t AS (
SELECT 1 id, 2 x, 3 y, STRUCT(STRUCT(STRUCT(10 AS c,'test' AS d) AS b,'field2' AS field2) AS a) xyz, 4 v, 5 w
)
SELECT * REPLACE (
(
SELECT AS STRUCT (
SELECT AS STRUCT (
SELECT AS STRUCT * EXCEPT(d)
FROM UNNEST([xyz.a.b]) b
) b,
xyz.a.field2
) a
) AS xyz)
FROM t