Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Standard SQL Data Types Not Supported in gcloud._helpers._rows_from_json() / _CELLDATA_FROM_JSON() #2229

Closed
KevinTydlacka opened this issue Aug 31, 2016 · 5 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@KevinTydlacka
Copy link

Standard SQL dialect support was added in 0.18.0, but current release does not support queries that return results that include data types that are not supported by Legacy SQL.

E.g. executing the following query using Standard SQL:

SELECT PARSE_DATE('%Y%m%d', '20160810') AS table_date;

results in

rows = query.rows
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gcloud/bigquery/query.py", line 204, in rows
    return _rows_from_json(self._properties.get('rows', ()), self.schema)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gcloud/bigquery/_helpers.py", line 85, in _rows_
from_json
    converter = _CELLDATA_FROM_JSON[field.field_type]
KeyError: u'DATE'

Not a significant issue since the Legacy SQL Data types will work for my needs, but wanted to report it all the same.

@dhermes dhermes added api: bigtable Issues related to the Bigtable API. api: bigquery Issues related to the BigQuery API. and removed api: bigtable Issues related to the Bigtable API. labels Sep 2, 2016
@tseaver tseaver added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Sep 6, 2016
@tseaver tseaver self-assigned this Sep 6, 2016
@tseaver
Copy link
Contributor

tseaver commented Sep 6, 2016

@toomtoom Thanks for the report! For future reference, here are the docs for the column types returned when querying with the standard SQL dialect.

@abovethewater
Copy link

abovethewater commented Sep 19, 2016

Unfortunately there is no equivalent timezone functionality in the legacy SQL syntax, so this is a bit of an issue.

For anyone else blocked by this, the query actually works, and the raw data is available via

query._properties['rows']

If there is a preferable way to access this until fixed, then please recommend.

@daspecster
Copy link
Contributor

daspecster commented Sep 19, 2016

@tseaver
Copy link
Contributor

tseaver commented Sep 19, 2016

@abovethewater, @toomtoom, @daspecster

  • PR Support parsing DATE columns from Standard SQL tables #2265 added support for the DATE type.
  • We should be able to add the INT64 and FLOAT64 standard types as trivial aliases for the legacy INT and FLOAT.
  • The standard BYTES type should be straightforward, if we can figure out how the back-end is expecting the values to be tunneled via JSON (I expect base64, but can't find it in the docs).
  • Support for both ARRAY and STRUCT are going to require reworking the current implementation, as the field types are no longer constant strings.

@tseaver
Copy link
Contributor

tseaver commented Dec 5, 2016

AFAICT, the remaining standard SQL types which need support are BYTES (I just verified that the back-end marshals them as base64) and TIME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants