1

I am unable to select a column named: event_params.value.string_value

Here's my code:

SELECT
  DISTINCT (event_params.value.string_value)
FROM
  `data-22.events_20200914`

My error:

Cannot access field value on a value with type ARRAY<STRUCT<key STRING, value STRUCT<string_value STRING, int_value INT64, float_value FLOAT64, ...>>> at [2:26]

4
  • What error do you get? What is the structure of the data? Sample data and desired results would help. Commented Sep 15, 2020 at 15:10
  • This is the error I got: Cannot access field value on a value with type ARRAY<STRUCT<key STRING, value STRUCT<string_value STRING, int_value INT64, float_value FLOAT64, ...>>> at [2:26] Commented Sep 15, 2020 at 15:11
  • I am sorry, I can't provide the dataset. Commented Sep 15, 2020 at 15:12
  • . . No one is asking for or wants actual data, just representative values to understand the question. Commented Sep 15, 2020 at 15:14

1 Answer 1

2

Presumably you want:

SELECT DISTINCT event_param.value.string_value
FROM `mybits-54f8c.analytics_179636122.events_20200914 a CROSS JOIN
     UNNEST(event_params) event_param;

But this is just a guess.

1
  • Thank you so much @Gordon Linoff!! It is working perfectly fine. Commented Sep 15, 2020 at 15:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.