Comments (5)
I can take a look at this soon if you could assign it to me @totem3.
I have a pending PR up that fixes some API-level value encoding issues similar to this one at goccy/go-zetasqlite#111
from bigquery-emulator.
The behaviour for TIMESTAMP fields of records is also affected (and maybe also others)
In this case, selecting the record returns '2023-08-01T21:22:23Z' for the inserted timestamp value 2023-08-01T21:22:23.123456Z
. Educated guess is that the expected results should be a numeric timestamp value. Also the precision of the returned value is degraded.
bq
outputs for this case
SELECT * FROM record_test
+------------------------------------------------------------------------------------------------+
| rec |
+------------------------------------------------------------------------------------------------+
| {"numeric_value":"47123456789/1000000000","timestamp_value":"<date out of range for display>"} |
+------------------------------------------------------------------------------------------------+
SELECT rec.timestamp_value FROM record_test
+---------------------+
| timestamp_value |
+---------------------+
| 2023-08-01 21:22:23 |
+---------------------+
from bigquery-emulator.
Thank you for the detailed report.
I have confirmed that there are indeed differences in output compared to BigQuery, and also outputs vary between values within a structure and those that are not.
I briefly investigated the cause and would like to document it.
Internally, in go-zetasqlite which we use for constructing responses, there is a difference in the method of construction for structured and non-structured data.
For Numeric types, we convert to a string using NumericValue
's ToString
.
https://github.com/goccy/go-zetasqlite/blob/e0a36047b564fab7bc36f17031c86225dabf9fea/internal/rows.go#L246-L251
In the case of a Struct, we first convert it to a StructValue
using StructValue
's ToStruct
.
https://github.com/goccy/go-zetasqlite/blob/e0a36047b564fab7bc36f17031c86225dabf9fea/internal/rows.go#L297-L302
Then, we use StructValue
's Interface
to convert it to interface{}
. In this process, we recursively call Interface
for each field to convert all fields.
The definition of NumericValue
's Interface
is as follows, nv.Rat.String()
.
https://github.com/goccy/go-zetasqlite/blob/e0a36047b564fab7bc36f17031c86225dabf9fea/internal/value.go#L798-L800
This indeed returns a value like 47123456789/1000000000
.
On the other hand, the definition of ToString
is as follows, which indeed returns a value like 47.123456789
.
Due to these differences, it seems that outputs within structures are different for other types as well.
from bigquery-emulator.
Thank you for your response. As I havenโt started working on it yet, I would be grateful if you could address this issue.
from bigquery-emulator.
I haven't taken a look at this yet. If you have some time @totem3, that'd be appreciated.
I'm currently looking at if it'd be possible to rewrite how go-zetasqlite handles window functions to fix goccy/go-zetasqlite#153 and goccy/go-zetasqlite#161 as it'd block our usage from further adoption.
from bigquery-emulator.
Related Issues (20)
- Storage API Avro encoding does not work with nullable fields
- return 409 on dataset duplicate
- Library blocks compiling HOT 2
- Support for SSL/TLS in gRPC for spark compatibility
- `/projects/{projectId}/queries/{jobId}` endpoint does not respect the `maxResults` query parameter
- Use Emulator with PySpark HOT 1
- Cant parametrize FLOAT value in query HOT 9
- `Too many SQL variables` when inserting data HOT 2
- When names of tables start with same string, _TABLE_SUFFIX expansion may fail
- Using JobId (in Java) when querying, causes 'no such table' error to be returned
- Replace SQLite with DuckDB
- Unmarshal fails to a struct with time.Time type when using the cloud.google.com/go/bigquery library HOT 5
- Queries on TIMESTAMP columns are not handled correctly when no timezone is specified HOT 1
- failed to add query result to dynamic destination table (on a simple query) HOT 4
- How to install and run this project locally on my computer? HOT 6
- JSON_EXTRACT_SCALAR nor JSON_QUERY does not work as expected HOT 1
- Connection error when creating a dataset HOT 8
- Does the emulator work with Pandas GBQ? HOT 3
- Error when executing bq command from google-cloud-cli version 469.0.0
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.