Creating a new table within a dataset

The following code creates a table within the specified dataset with the given schema. The code checks whether the given table is already created under the specified dataset; if the table does not exist, it creates the new table. The table schema can be plaintext in which each column specification is delimited by, and each column is specified in, the format ColumnName:DataType. In the schema provided as plaintext, all columns are assumed to be NULLABLE. The table schema can also be in JSON format, which provides the option to specify the mode for the columns; they can be one of the following:

  • NULLABLE: The column allows null values to be stored in it
  • REPEATED: The column allows storing of nested objects in it and each property can specify the mode required
  • REQUIRED: The column does not allow null values to be stored in it

When creating a table, a default expiration time can also be specified using the CreateTableOptions.Expiration property; it is applied only to that table:

Call the CreateNewTable method in the main method and pass the dataset name and the table name for creation:

BigQuery also provides the option to create table and track records inserted on a daily basis and delete only those records inserted on a particular date. These tables are called Partitioned Tables, which contain a timestamp column, _PARTITIONTIME. The data can be queried by using this column to filter records inserted on a particular date. Each day's data can be queried as a separate table. To create partition tables via API, use the CreateTableOptions.TimePartitionType property and set its value to TimePartitionType.Day. BigQuery also provides options to delete records inserted on a particular date after X number of days automatically on an ongoing basis. To use this feature specify, the CreateTableOptions.TimePartitionExpiration property.

Updating and deleting records from a partition table should be done at the partition level and it cannot be done at the whole-table level.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.218.221