Skip to content

Error while trying to create the dataset table #10

Description

@clorichel

First thing first: thank you for this target guys!

Been struggling with this one for a bit, hoping someone could help:

Traceback (most recent call last):
  File "/root/.virtualenvs/target-bigquery/lib/python3.7/site-packages/target_bigquery-1.4.0-py3.7.egg/target_bigquery.py", line 243, in persist_lines_stream
  File "/root/.virtualenvs/target-bigquery/lib/python3.7/site-packages/google_cloud_bigquery-1.14.0-py3.7.egg/google/cloud/bigquery/client.py", line 408, in create_table
    api_response = self._call_api(retry, method="POST", path=path, data=data)
  File "/root/.virtualenvs/target-bigquery/lib/python3.7/site-packages/google_cloud_bigquery-1.14.0-py3.7.egg/google/cloud/bigquery/client.py", line 419, in _call_api
    return call()
  File "/root/.virtualenvs/target-bigquery/lib/python3.7/site-packages/google_api_core-1.11.1-py3.7.egg/google/api_core/retry.py", line 273, in retry_wrapped_func
    on_error=on_error,
  File "/root/.virtualenvs/target-bigquery/lib/python3.7/site-packages/google_api_core-1.11.1-py3.7.egg/google/api_core/retry.py", line 182, in retry_target
    return target()
  File "/root/.virtualenvs/target-bigquery/lib/python3.7/site-packages/google_cloud_core-1.0.2-py3.7.egg/google/cloud/_http.py", line 396, in api_request
    raise exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 POST https://www.googleapis.com/bigquery/v2/projects/redactedproject/datasets/redacteddataset/tables: Invalid value for type: NULL is not a valid value

The dataset is created just fine 👌 if it doesn't exist, but code always fails while trying to create the table. I've voluntarily added the BadRequest exception to intercept the table name with:

except exceptions.Conflict:
    pass
except exceptions.BadRequest:
    raise Exception("BadRequest, msg is {}".format(msg))

And here it is:

Exception: BadRequest, msg is {'type': 'SCHEMA', 'stream': 'reviews', 'schema': {'type': ['object'], 'properties': {'id': {'type': 'integer'}, 'created_at': {'type': 'string', 'format': 'date-time'}, 'updated_at': {'type': 'string', 'format': 'date-time'}, 'votes_up': {'type': 'number'}, 'votes_down': {'type': 'number'}, 'score': {'type': 'number'}, 'content': {'type': 'string'}, 'title': {'type': ['string', 'null']}, 'email': {'type': ['string', 'null']}, 'sentiment': {'type': ['number', 'null']}, 'sku': {'type': 'string'}, 'name': {'type': 'string'}, 'reviewer_type': {'type': 'string'}, 'deleted': {'type': 'boolean'}, 'user_reference': {'type': ['null', 'string']}}, 'additionalProperties': False}, 'key_properties': ['id']}

This msg seems valid to me: table = msg.stream and if I print it it's reviews as expected. What did I miss?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions