Skip to content

createTable - Required parameter is missing #1422

Description

@mlynch

I'm creating a table with an existing dataset like this:

var bigquery = gcloud.bigquery({
  projectId: 'ionic-stats-storage',
  keyFilename: './bigquery.json'
});

var cliDataset = bigquery.dataset('CLI');
cliDataset.createTable(type, {
        schema: {
          fields: [
            { type: 'string', name: 'type' },
            { type: 'string', name: 'service' },
            { type: 'string', name: 'uuid' },
            { type: 'timestamp', name: 'created_at' },
            { name: 'data', fields: fields }
          ]
        }
      }, function(err, table, apiResponse) {
...
});

This is the payload being sent to the /tables endpoint as I inspected it in the gcloud node library (pretty-printed):

{
  "schema": {
    "fields": [
      {
        "type": "string",
        "name": "type"
      },
      {
        "type": "string",
        "name": "service"
      },
      {
        "type": "string",
        "name": "uuid"
      },
      {
        "type": "timestamp",
        "name": "created_at"
      },
      {
        "name": "data",
        "fields": [
          {
            "name": "favorite_flavor",
            "type": "string"
          }
        ]
      }
    ]
  },
  "tableReference": {
    "datasetId": "CLI",
    "projectId": "ionic-stats-storage"
  }
}

The API is returning a vague error about a missing required parameter, but doesn't say which one, and I believe I'm using the node API correctly (very possible I'm not). Note: I also tried removing the data record in case I wasn't doing that properly, but I receive the same response:

{ ApiError: Required parameter is missing
    at new util.ApiError (/Users/max/git/ionic-track/node_modules/gcloud/lib/common/util.js:106:10)
    at Object.parseHttpRespBody (/Users/max/git/ionic-track/node_modules/gcloud/lib/common/util.js:184:30)
    at Object.handleResp (/Users/max/git/ionic-track/node_modules/gcloud/lib/common/util.js:124:18)
    at /Users/max/git/ionic-track/node_modules/gcloud/lib/common/util.js:447:12
    at Request.onResponse [as _callback] (/Users/max/git/ionic-track/node_modules/retry-request/index.js:120:7)
    at Request.self.callback (/Users/max/git/ionic-track/node_modules/request/request.js:187:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/max/git/ionic-track/node_modules/request/request.js:1044:10)
    at emitOne (events.js:96:13)
  code: 400,
  errors:
   [ { domain: 'global',
       reason: 'required',
       message: 'Required parameter is missing' } ],
  response: undefined,
  message: 'Required parameter is missing' }

Activity

  1. stephenplusplus commented on Jul 12, 2016

    @stephenplusplus
    Contributor

    I believe this should work:

    cliDataset.createTable(type, {
      schema: {
        fields: [
          { type: 'string', name: 'type' },
          { type: 'string', name: 'service' },
          { type: 'string', name: 'uuid' },
          { type: 'timestamp', name: 'created_at' },
          {
            name: 'data',
            type: 'record', // <-- new
            fields: [
              {
                type: 'string',
                name: 'favorite_flavor'
              }
            ]
          }
        ]
      }
    }, function(err, table, apiResponse) {
      // ...
    });
  2. added
    type: questionRequest for information or clarification. Not an issue.
    api: bigqueryIssues related to the BigQuery API.
    on Jul 12, 2016
  3. mlynch commented on Jul 12, 2016

    @mlynch
    Author

    Okay, I figured out what I was doing wrong here. First, my table id was undefined since I was sending incorrect data to my API. However, in the process of tweaking things and trying to get this to work, I tried using the id sub record as per #954 which does not seem to work yet. Additionally, sub-records need the 'record' type but using them is not documented in the API docs anywhere. Making those changes works now 👯

    @stephenplusplus thanks for the help!

  4. stephenplusplus commented on Jul 12, 2016

    @stephenplusplus
    Contributor

    Yeah, I think we can make this easier. We try to focus on the common use cases and decorate them to make things easier. This leaves holes where we link to the upstream API docs to show all of the options (https://cloud.google.com/bigquery/docs/reference/v2/tables#resource) from our docs (https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.36.0/bigquery/dataset?method=createTable).

    Making this easier should be pretty... easy. I'll re-open this issue and ping you when I have a PR, if you don't mind. Thanks for calling this out!

  5. mlynch commented on Jul 12, 2016

    @mlynch
    Author

    Sounds great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions