I am trying to use BigQuery Standard SQL with Python API, though I cannot execute the query that ran successfully in WEB UI.
Basically, I am splitting a string and then using OFFSET keyword to get the value at a particular index. As follows:
CASE WHEN t.depth = 1 THEN '' WHEN t.depth = 2 THEN '' WHEN t.depth = 3 THEN '' WHEN t.depth = 4 THEN '' WHEN t.depth = 5 THEN '' WHEN t.depth = 6 THEN t.curr WHEN t.depth = 7 THEN SPLIT(t.ancestry,'/')[OFFSET(6)] ELSE '' END AS level7,
CASE WHEN t.depth = 1 THEN '' WHEN t.depth = 2 THEN '' WHEN t.depth = 3 THEN '' WHEN t.depth = 4 THEN '' WHEN t.depth = 5 THEN t.curr WHEN t.depth = 6 THEN SPLIT(t.ancestry,'/')[OFFSET(5)] WHEN t.depth = 7 THEN SPLIT(t.ancestry,'/')[OFFSET(5)] ELSE '' END AS level6,
The above code runs without an issue in WEB UI, whereas using Python API and setting useLegacySQL = False, I get the following error
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/bigquery/v2/projects/*************
returned "Encountered " "]" "[OFFSET(6)] "" at line 7, column 217. Was expecting: "END" ...">
Any help is appreciated.