standard bigquery v2, support nested schema in query result
Please support nested schema field names in complex queries like SELECT ARRAY[STRUCT(1 AS a, 2 AS b, 3 AS c)] AS d
const BigQuery = require('@google-cloud/bigquery'); > BigQuery().query({ query: 'SELECT 1 AS cnt', useLegacySql: false }, function (err, data) { if (err) return console.error(err); console.dir(data, { depth: null, colors: true }); }); > [ { cnt: 1 } ]
This is right, the field name cnt is correctly used
> BigQuery().query({ query: 'SELECT ARRAY[STRUCT(1 AS a, 2 AS b, 3 AS c)] AS d', useLegacySql: false }, function (err, data) { if (err) return console.error(err); console.dir(data, { depth: null, colors: true }); }); > [ { d: [ { v: { f: [ { v: '1' }, { v: '2' }, { v: '3' } ] } } ] } ]
- only the outer level field name
dis in use, not others a, b, c, - all get default
fandv, and all their values type, the 1,2,3 here should be integers
I have even more complex queries than this, all are like this only the outer one level schema field names / value types are got populated
A raw query over HTTP, the http tool is from httpie, just an advanced version of curl; after I get access token with same httpie tool from token allocation, I can do queries like this on command line, here the server response included correct schema with nested fields, so technically it should be possible to populate all inner level field names and value types correct
➸ time http --verbose --pretty=colors POST https://www.googleapis.com/bigquery/v2/projects/XXXXXXX/queries 'Authorization: Bearer XXXXXXXXXXXX' useLegacySql=false useQueryCache=false query='SELECT ARRAY[STRUCT(1 AS a, 2 AS b, 3 AS c)] AS d' POST /bigquery/v2/projects/XXXXXXXXXXXXXX/queries HTTP/1.1 Content-Length: 113 Accept-Encoding: gzip, deflate Host: www.googleapis.com Accept: application/json, */* User-Agent: HTTPie/0.9.6 Connection: keep-alive Content-Type: application/json Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXX {"useLegacySql": "false", "useQueryCache": "false", "query": "SELECT ARRAY[STRUCT(1 AS a, 2 AS b, 3 AS c)] AS d"} HTTP/1.1 200 OK Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: Mon, 01 Jan 1990 00:00:00 GMT Date: Wed, 14 Sep 2016 17:37:03 GMT ETag: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" Vary: Origin Vary: X-Origin Content-Type: application/json; charset=UTF-8 Content-Encoding: gzip X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block Server: GSE Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32" Transfer-Encoding: chunked { "kind": "bigquery#queryResponse", "schema": { "fields": [ { "name": "d", "type": "RECORD", "mode": "REPEATED", "fields": [ { "name": "a", "type": "INTEGER", "mode": "NULLABLE" }, { "name": "b", "type": "INTEGER", "mode": "NULLABLE" }, { "name": "c", "type": "INTEGER", "mode": "NULLABLE" } ] } ] }, "jobReference": { "projectId": "XXXXXXXXXXXXX", "jobId": "job_XXXXXXXXXXXXXXXXXXXXXXXXXXX" }, "totalRows": "1", "rows": [ { "f": [ { "v": [ { "v": { "f": [ { "v": "1" }, { "v": "2" }, { "v": "3" } ] } } ] } ] } ], "totalBytesProcessed": "0", "jobComplete": true, "cacheHit": false } real 0m3.040s user 0m0.364s sys 0m0.020s
Environment details
- OS: Linux
- Node.js version: v6
I have search other issues here #1564 #1135 about nested schema, but for different purpose, I believe this ticket is different.