Skip to content
Advertisement

String array to int64 conversion

I’ve two tables and I need to join them.

But the common field are of different data types.

Table A – ID field is of string array and Table B ID is of Int64.

Tried to cast String array to Int 64 getting error “Invalid cast from ARRAY to INT64”

Is there anyway I can convert and join the tables.

Advertisement

Answer

So, from what I understand -> you are trying to cast an ARRAY<string> datatype to INT64 which is not possible

enter image description here

Error:

Instead, you gotta unnest the STRING ARRAY and cast the unnested flat STRING to INT64 and then join with table B

Complete Query Simulation:

Sample Result

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement