> For the complete documentation index, see [llms.txt](https://docs.coupler.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coupler.io/destinations/categories/database/big_query/faq/how-to-generate-bigquery-schema-to-define-column-types-manually.md).

# How to generate BigQuery schema to define column types manually?

Coupler.io allows defining schema for BigQuery destination table manually using JSON format. In the schema for each inserted column, we should define mode (required or not), the name of the column, and its type.

You still can use the BigQuery schema autodetection mechanism. For this keep the "Autodetect table schema" toggle turned ON:

<div align="left"><img src="https://s3.amazonaws.com/helpscout.net/docs/assets/57fbf3029033600277a688ab/images/6267cc1a93a48c4448335611/file-00B0T6nuTy.png" alt="" width="375"></div>

To provide schema manually in the Wizard turn OFF the "Autodetect table schema" toggle and enter schema to the "Columns schema" field:

<div align="left"><img src="https://s3.amazonaws.com/helpscout.net/docs/assets/57fbf3029033600277a688ab/images/6267cbe493a48c44483355f5/file-4GOlTvfkNV.png" alt="" width="375"></div>

The simplest schema for 1 required column with the name "id" and type "Integer" looks like this:

```json
[
   {
      "mode":"REQUIRED",
      "name":"id",
      "type":"INTEGER"
   }
]
```

Possible values for each attribute:

* **mode**:&#x20;
  * *REQUIRED* - for columns where the value cannot be empty (null)
  * *NULLABLE* - for columns where the value can be empty (null)
* **name** - valid column name. A column name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (\_), and it must start with a letter or underscore. The maximum column name length is 300 characters. [Read more details about validation for the name](https://cloud.google.com/bigquery/docs/schemas#column_names).
* **type** - valid column type supported by BigQuery. Please [read here the latest version of supported types](https://cloud.google.com/bigquery/docs/schemas#standard_sql_data_types). We also added below the most used types:
  * *STRING* - Variable-length character (Unicode) data (i.e. "Some string data")
  * *DATE* - A logical calendar date
  * *INTEGER* - Numeric values without fractional components (i.e. 55)
  * *FLOAT* - Approximate numeric values with fractional components (i.e. 12.64 (12,64))

Please review our example below:

**Source data: CSV**

```csv
time_ref,"account","code","country_code","product_type",value,"status"
202012,"Exports","00","AE","Goods",174134527.0,"F"
202012,"Exports","00","AF","Goods",5473.0,"F"
202012,"Exports","00","AG","Goods",426470.0,"F"
202012,"Exports","00","AI","Goods",13083.0,"F"
```

**Defined schema:**

```json
[
   {
      "mode":"REQUIRED",
      "name":"time_ref",
      "type":"NUMERIC"
   },
   {
      "mode":"NULLABLE",
      "name":"account",
      "type":"STRING"
   },
   {
      "mode":"NULLABLE",
      "name":"code",
      "type":"STRING"
   },
   {
      "mode":"NULLABLE",
      "name":"country_code",
      "type":"STRING"
   },
   {
      "mode":"NULLABLE",
      "name":"product_type",
      "type":"STRING"
   },
   {
      "mode":"NULLABLE",
      "name":"value",
      "type":"FLOAT"
   },
   {
      "mode":"NULLABLE",
      "name":"status",
      "type":"STRING"
   }
]
```

**Results in the BigQuery:**&#x20;

![](https://s3.amazonaws.com/helpscout.net/docs/assets/57fbf3029033600277a688ab/images/6267d41c6c886c75aabea3fb/file-tVjndXLNZ7.png)

#### Important notes: <a href="#important-notes-gf0y2" id="important-notes-gf0y2"></a>

1\. Please control that number of columns returned by the data source is the same. In case the number of columns increases - data flow execution fails as the schema is not appropriate. In case the number of columns decreases - data flow execution can fail as schema as invalid or data can import, but to the invalid columns.

2\. If you want to add the "Last updated at" column to the results of import:

<div align="left"><img src="https://s3.amazonaws.com/helpscout.net/docs/assets/57fbf3029033600277a688ab/images/6267c56e93a48c44483355cd/file-PufC7B2Jhh.png" alt="" width="375"></div>

You need to define this column and put it **first** in the schema:

```json
   {
      "mode":"REQUIRED",
      "name":"last_updated_at",
      "type":"STRING"
   }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coupler.io/destinations/categories/database/big_query/faq/how-to-generate-bigquery-schema-to-define-column-types-manually.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
