Comments (11)
Go's client library seems to expect float64 value as timestamp value ... 🤔
FYI: https://github.com/googleapis/google-cloud-go/blob/fee0f68b5005222a8bcf1f2c662d6587eac7bd0f/bigquery/value.go#L957-L966
from bigquery-emulator.
It expects Unix Timestamp with microseconds
format. e.g.) 1661864400.5699711
https://www.php.net/manual/en/datetime.formats.compound.php
The following client code causes an error.
https://github.com/googleapis/google-cloud-php-bigquery/blob/main/src/ValueMapper.php#L364
from bigquery-emulator.
@exageraldo
BigQuery uses float representation when returning timestamp type value, but when sending timestamp type value from client to BigQuery, it must be in the following format
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
So, you should use representation like 2022-01-01T00:00:00+09:00
as timestamp value
from bigquery-emulator.
Now it worked perfectly. Thanks a lot!
from bigquery-emulator.
I see ! I also found that in the docs
https://cloud.google.com/bigquery/docs/reference/rest/v2/DataFormatOptions
from bigquery-emulator.
Do you know what format php client expects for timestamp type ? e.g.) unixtime nano
or RFC3339 etc
from bigquery-emulator.
Thank you for your kind information !
This problem fixed with v0.1.9 !
Thanks
from bigquery-emulator.
Thanks!
from bigquery-emulator.
Hey, I'm trying to run it this way:
FROM ghcr.io/goccy/bigquery-emulator:0.1.9
COPY load-bigquery.yaml .
CMD ["bigquery-emulator", "--project=project-id", "--port=9050", "--database=saved-bigquery", "--data-from-yaml=load-bigquery.yaml"]
But I believe I'm facing the same problem initially reported here.
failed to convert value from {Name: Ordinal:2 Value:1.6618644e+09}: failed to convert TIMESTAMP from float64
load-bigquery.yam
:
projects:
- id: project-id
datasets:
- id: dataset-one
tables:
- id: some-tamble
columns:
- name: id
type: INT64
- name: record
type: STRING
- name: created_at
type: TIMESTAMP
- name: actor
type: STRING
- name: user
type: STRING
data:
- id: 0
record: add.user
created_at: 1661864400.5699711
actor: actor
user: user-one
Do I have to do something different?
from bigquery-emulator.
I use timestamp type by python bigquery library. And I got the following error.
I think timestamp format should return int
instead of float
. Do you think about it? Thank you.
https://github.com/googleapis/python-bigquery/blob/main/google/cloud/bigquery/_helpers.py#L207
Traceback (most recent call last):
File "/Users/kitagry/go/src/github.com/kitagry/bigquery-test/a.py", line 155, in <module>
res = emulator.query(sql)
File "/Users/kitagry/go/src/github.com/kitagry/bigquery-test/a.py", line 98, in query
return self.client.query(sql).to_dataframe(create_bqstorage_client=False)
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/job/query.py", line 1696, in to_dataframe
return query_result.to_dataframe(
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/table.py", line 1985, in to_dataframe
record_batch = self.to_arrow(
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/table.py", line 1779, in to_arrow
for record_batch in self.to_arrow_iterable(
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/table.py", line 1635, in _to_page_iterable
yield from result_pages
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/_pandas_helpers.py", line 631, in download_arrow_row_iterator
yield _row_iterator_page_to_arrow(page, column_names, arrow_types)
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/_pandas_helpers.py", line 598, in _row_iterator_page_to_arrow
next(iter(page))
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/api_core/page_iterator.py", line 131, in __next__
result = self._item_to_value(self._parent, item)
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/table.py", line 2684, in _item_to_row
_helpers._row_tuple_from_json(resource, iterator.schema),
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/_helpers.py", line 430, in _row_tuple_from_json
row_data.append(_field_from_json(cell["v"], field))
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/_helpers.py", line 406, in _field_from_json
return converter(resource, field)
File "/Users/kitagry/Library/Caches/pypoetry/virtualenvs/bigquery-test-5qsCeeNA-py3.9/lib/python3.9/site
-packages/google/cloud/bigquery/_helpers.py", line 272, in _timestamp_from_json
return _datetime_from_microseconds(int(value))
ValueError: invalid literal for int() with base 10: '1666353600.0'
from bigquery-emulator.
Ok, I understand it. Python client send formatOptions.useInt64Timestamp = true
. So, I think emulator should implement thi s option in order to use timestamp in python library.
googleapis/python-bigquery@04510a7
from bigquery-emulator.
Related Issues (20)
- Support for SEARCH queries / search index
- Support for batch inserts
- How to connect the BQ emulator via dbeavor or dbvisualizer? HOT 3
- Did the WriteStream API forget to commit the transaction when the WriteStream Type is set to WriteStream_COMMITTED?
- Add the installation guide with aqua to the document
- Error processing job with UNNEST and query parameters HOT 1
- Split fails with NULL, while BigQuery just returns no results HOT 1
- Running binary twice always gives error
- BigQuery Emulator Returns NULL for Empty Arrays HOT 1
- C# client HOT 3
- The return value of FORMAT_DATE('%u', date) HOT 1
- Support for the "LAX" functions (e.g. LAX_INT64) HOT 1
- DATE_TRUNC with ISO_WEEK HOT 2
- Trouble Integrating BigQuery Emulator with Write Streams Java Library : runtime error: invalid memory address or nil pointer dereference HOT 3
- `_default` WriteStream not supported HOT 1
- `COMMITTED` write stream don't seem to work. HOT 1
- Table.getNumRows is null (numRows field not populated eventhough the table has rows) HOT 1
- Storage API Avro encoding does not work with nullable fields
- return 409 on dataset duplicate
- Library blocks compiling HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigquery-emulator.