Skip to content

[BigQuery] Can't insert correct TIMESTAMP. #1247

@kamatama41

Description

@kamatama41

In my environment, I can't insert correct data to the TIMESTAMP column.

  • gcloud 0.8.0
  • Python 2.7.10
  • MacOS X 10.10.5

The following snippet is the smallest reproducible example.
Please let me know that it's a bug or my mistake.

import os
from datetime import datetime
from gcloud import bigquery

GCP_KEY_PATH = os.path.join(os.path.dirname(__file__), './gcpkey.json')
project_id = 'my_project'
dataset = 'tmp'
table_name = 'test'

bq = bigquery.Client.from_service_account_json(GCP_KEY_PATH, project=project_id)
table = bq.dataset(dataset).table(name=table_name)

if not table.exists():
    table.schema = [bigquery.SchemaField('time', 'TIMESTAMP')]
    table.create()

table.reload()
rows = [[datetime.now()]]
table.insert_data(rows)

2015-11-28 15 47 08

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions