Why am I getting the error Java::JavaLang::ClassCastException: [Mentions BigQuery]

Knowledge Drop

Last tested: Feb 7, 2018
 

You may be getting this error because Looker's SQL Runner is unable to return Arrays in the query results. If the column is a type Array and is in the Select statement, users may encounter the error Java::JavaLang::ClassCastException:

When using arrays, it may be necessary to UNNEST or convert Array to String. A couple functions that can solve for this error are:

Google BigQuery

 

UNNEST

The UNNEST operator takes an ARRAY and returns a table, with one row for each element in the ARRAY. You can also use UNNEST outside of the FROM clause with the IN operator.

Converting Arrays to Strings

The ARRAY_TO_STRING() function allows you to convert an ARRAY<STRING> to a single STRING value or an ARRAY<BYTES> to a single BYTES value where the resulting value is the ordered concatenation of the array elements.

See Google Documentation here for more information:

https://cloud.google.com/bigquery/docs/reference/standard-sql/arrays

This content is subject to limited support.                

Version history
Last update:
‎07-07-2021 01:12 PM
Updated by: