I am trying simple split function in Bigquery SQL and trying to get the array elements (query taken from hive SQL). But Bigquery SQL split function is making the fields repeatable and does not give desired results. Can someone help create similar query in Bigquery #standardSQL
-- Hive query
select hierarchy, hier_array, hier_array[0] as level0, hier_array[1] as level1, hier_array[2] as level2
from
(
select hierarchy, split(hierarchy,'-') as hier_array
from gcs_publish.cr_party_dnm_gu_rel
) z
limit 10;
--Output desired
hierarchy hier_array level0 level1
10000-211817-26510-25429 ["10000","211817","26510","25429"] 10000 211817
10019-10369 ["10019","10369"] 10019 10369
10021 ["10021"] 10021
10022-17256 ["10022","17256"] 10022 17256
10033 ["10033"] 10033
10037-3098187 ["10037","3098187"] 10037 3098187
10042 ["10042"] 10042
10050-11038-211637808-34880075 ["10050","11038","211637808","34880075"] 10050 11038
10052 ["10052"] 10052
10053 ["10053"] 10053