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)
- 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
- Response from table update is incompatible with Google's Python SDK HOT 1
- Improve emulator performance for large projects HOT 7
- Failes to exec merge statement UPDATE
- Cannot create a view with a query that ends in semicolon
- Cannot materialize job results when table does not yet exist
- [Golang] Errors from zetasql parser HOT 3
- The BigQuery emulator doesn't support CREATE TABLE AS SELECT with column definition list HOT 2
- Error querying a nested struct using UNNEST HOT 1
- Support of UNPIVOT operator HOT 3
- `UPDATE ... FROM ( SELECT ... )` results in the error: `Update with joins not supported`
- Unable to use UploadCsvAsync HOT 1
- Error checking null string parameter in where clause HOT 1
- BQ-Emulator does not release memory when deleting tables
- Python SDK always retries requests for invalid queries
- Ingestion-time partitioning not (fully) supported HOT 1
- Support for the `bqutil` community user-defined functions
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.