Using a JSON Schema file in BigQuery for creating a Schema.

0 votes
I don't want to manually create a schema so I have created a JSON schema file for the same. How do I use this file to create a Schema?
Nov 15, 2019 in GCP by anonymous
• 6,260 points
1,591 views

1 answer to this question.

0 votes

After creating your JSON schema file, you can specify it on the command line. You cannot use a schema file with the GCP Console, the classic BigQuery web UI, or the API.

Manually supply the schema file using the:

  • load command if you are loading data

  • mk command if you are creating an empty table

When you supply a JSON schema file, it must be stored in a locally readable location. You cannot specify a JSON schema file stored in Cloud Storage or Google Drive.

Specifying a schema file when you load data

The following command loads data into a table using the schema definition in a JSON file:

bq --location=location load \
--source_format=format \
project_id:dataset.table \
path_to_data_file \
path_to_schema_file

Where:

  • location is the name of your location. 

  • format is NEWLINE_DELIMITED_JSON or CSV.

  • project_id is your project ID.

  • dataset is the dataset that contains the table into which you're loading data.

  • table is the name of the table into which you're loading data.

  • path_to_data_file is the location of the CSV or JSON data file on your local machine or in Cloud Storage.

  • path_to_schema_file is the path to the schema file on your local machine.

Specifying a schema file when you create a table

The following command creates an empty table in an existing dataset using the schema definition in a JSON file:

bq mk --table project_id:dataset.table path_to_schema_file

Where:

  • project_id is your project ID.

  • dataset is a dataset in your project.

  • table is the name of the table you're creating.

  • path_to_schema_file is the path to the schema file on your local machine.

answered Nov 15, 2019 by Sirajul
• 58,130 points

Related Questions In GCP

0 votes
1 answer

Creating a SQL Server instance using Google Compute engine.

Google Compute Engine provides public images preconfigured with ...READ MORE

answered Sep 23, 2019 in GCP by Sirajul
• 58,130 points
524 views
0 votes
1 answer

Creating password for a windows instance on GCP

Windows Server instances use password authentication instead ...READ MORE

answered Sep 24, 2019 in GCP by Sirajul
• 58,130 points
1,204 views
0 votes
1 answer

How do I import a OVA file in GCP?

Add the virtual appliance to Cloud Storage. To import ...READ MORE

answered Oct 21, 2019 in GCP by Sirajul
• 58,130 points
1,583 views
0 votes
2 answers
0 votes
1 answer

Assign access control to a BigQuery Dataset.

You can apply access controls during dataset creation by ...READ MORE

answered Nov 15, 2019 in GCP by Sirajul
• 58,130 points
408 views
0 votes
1 answer

Permissions required to update a dataset.

At a minimum, to update dataset properties, ...READ MORE

answered Nov 15, 2019 in GCP by Sirajul
• 58,130 points
230 views
0 votes
1 answer

Change default expiration time for a dataset.

You can update a dataset's default table ...READ MORE

answered Nov 15, 2019 in GCP by Sirajul
• 58,130 points
196 views
0 votes
1 answer