Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery error: Cannot query the cross product of repeated fields

I am running the following query on Google BigQuery web interface, for data provided by Google Analytics:

SELECT *
FROM [dataset.table]
WHERE
  hits.page.pagePath CONTAINS "my-fun-path" 

I would like to save the results into a new table, however I am obtaining the following error message when using Flatten Results = False:

Error: Cannot query the cross product of repeated fields customDimensions.value and hits.page.pagePath.

This answer implies that this should be possible: Is there a way to select nested records into a table?

Is there a workaround for the issue found?

like image 878
Silvia Pina Avatar asked May 22 '15 15:05

Silvia Pina


1 Answers

Depending on what kind of filtering is acceptable to you, you may be able to work around this by switching to OMIT IF from WHERE. It will give different results, but, again, perhaps such different results are acceptable. The following will remove entire hit record if (some) page inside of it meets criteria. Note two things here:

  • it uses OMIT hits IF, instead of more commonly used OMIT RECORD IF).
  • The condition is inverted, because OMIT IF is opposite of WHERE

The query is:

SELECT *
FROM [dataset.table]
OMIT hits IF EVERY(NOT hits.page.pagePath CONTAINS "my-fun-path")
like image 89
Mosha Pasumansky Avatar answered Sep 28 '22 07:09

Mosha Pasumansky