Skip to content

Error when running BiqQuery query with APPROX_QUANTILES #2804

Description

@tebeka
  1. OS type and version - Ubuntu 16.04.1 LTS
  2. Python version and virtual environment information python --version - 2.7.12
  3. google-cloud-python version pip show google-cloud, pip show google-<service> or pip freeze - 0.21.0
  4. Stacktrace if available
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-1528bd7c380f> in <module>()
----> 1 job.rows()
/home/mtebeka/python-docs-samples/appengine/flexible/hello_world/venv/local/lib/python2.7/site-packages/google/cloud/bigquery/query.pyc in rows(self)
225 :returns: fields describing the schema (None until set by the server).
226 """
--> 227 return _rows_from_json(self._properties.get('rows', ()), self.schema)
228 229 @property
/home/mtebeka/python-docs-samples/appengine/flexible/hello_world/venv/local/lib/python2.7/site-packages/google/cloud/bigquery/_helpers.pyc in _rows_from_json(rows, schema)
114 def _rows_from_json(rows, schema):
115 """Convert JSON row data to rows with appropriate types."""
--> 116 return [_row_from_json(row, schema) for row in rows]
117 118 /home/mtebeka/python-docs-samples/appengine/flexible/hello_world/venv/local/lib/python2.7/site-packages/google/cloud/bigquery/_helpers.pyc in _row_from_json(row, schema)
105 if field.mode == 'REPEATED':
106 row_data.append([converter(item, field)
--> 107 for item in cell['v']])
108 else:
109 row_data.append(converter(cell['v'], field))
/home/mtebeka/python-docs-samples/appengine/flexible/hello_world/venv/local/lib/python2.7/site-packages/google/cloud/bigquery/_helpers.pyc in _float_from_json(value, field)
33 """Coerce 'value' to a float, if set or not nullable."""
34 if _not_null(value, field):
---> 35 return float(value)
36 37 TypeError: float() argument must be a string or a number
  1. Steps to reproduce - Run a query with APPROX_QUANTILES.
  2. Code example
fromgoogle.cloudimportbigqueryclient=bigquery.Client(project='PROJECT-ID')
sql='''SELECTAPPROX_QUANTILES( CASE WHEN ctr_before = 0 THEN NULL ELSE (ctr_after - ctr_before) / ctr_before END, 100) quantileFROM `ltv.user_ctr` '''job=client.run_sync_query(sql)
job.use_legacy_sql=Falsejob.run()
job.rows

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions