Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Write


Description:

This Snap allows you to load data into BigQuery easily leveraging the jobs and query APIs. A complete list of supported queries as well as examples are documented here: https://cloud.google.com/bigquery/query-reference.

  • Expected upstream SnapsThe Snap will expose a schema of the selected table that can be mapped using Mapper or any other Snap that has the same schema as the table selected.
  • Expected downstream SnapsMapper or [None]
  • Expected input[None]
  • Expected outputCount of the number of records successfully inserted / Erroneous records are written out to the Error view.
Note
titleSnaps in Google BigQuery Snap Pack
  • Write datetime values to the database tables, always in UTC format.

  • Convert any non-UTC values in the incoming data to UTC before writing them.

  • Consider datetime values without the time zone mentioned, as in UTC.

So, ensure that you include the time zone in all the datetime values that you load into Google BigQuery tables using this Snap.

For example: "2020-08-29T18:38:07.370 America/Los_Angeles", “2020-09-11T10:05:14.000-07:00", “2020-09-11T17:05:14.000Z”


Prerequisites:

[None]


Support, limitations, and known issuesWorks in Ultra Task Pipelines.

Known Issue

Copying data by creating a table with the same name in Google BigQuery immediately after deleting it, may not insert the rows as expected. This behavior is due to the way the tables are cached and the internal table ID is propagated throughout the system. 

Workaround

We recommend you avoid rewriting in Google BigQuery and suggest the following workarounds. You can choose to use them individually or in unison, to suit your requirement.

  • Truncate the existing table instead of deleting it.

  • Add some randomly generated prefix to the table name each time you create the table (new or unique table name every time).

Behavior ChangeIn the 4.27 (427patches13615) release and later, pipelines that truncated (or deleted and re-created) a table and then used the Google BigQuery Write or Google BigQuery Bulk Load (Streaming) Snaps were allowed to retry the load operation. This lead to potential data loss because Google BigQuery uses an eventually consistent backend where one server might respond that it’s okay to write, but other servers still truncate the table.

In the 4.32 (432patches20298) release and later, we disabled retries on truncated tables in these two Snaps to prevent a potential loss of data. We recommend that you use the BigQuery Bulk Load (Cloud Storage) Snap instead.
Account: 

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Google BigQuery Account for information on the type of account to use.


Views:


InputThis Snap has exactly one document input view. By connecting a Snap like Mapper, the schema of the selected table maybe viewed and mapped to send data into the columns.
OutputThis Snap has at most one document output view that displays the number of records successfully inserted into the BigQuery table.
ErrorThis Snap has at most one document error view and produces zero or more documents in the view. The error view would contain error, reason, resolution and stack trace like invalid queries, column names, and so on.


Settings

Label


Insert excerpt
File Writer
File Writer
nopaneltrue

Project ID 

Required. This drop-down shows you a list of all the available projects that your user Account has access to. Clicking on the drop-down always pulls the latest list of available projects. The project on which the query should be executed should be selected.


Dataset ID


Required. After selecting the project, this drop-down will be populated with the list of available datasets in the Project.


Table ID


Required. After selecting the dataset, this drop-down will be populated with the list of available tables in the project. All the tables in BigQuery can also be viewed from the BigQuery console and entered directly into this field.


Create table if not present

Whether the table should be automatically created if not already present.

Default value: Not selected

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute


Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute


Note
titleWriting numeric values into Google BigQuery tables

Google BigQuery tables support columns with NUMERIC data type to allow storing big decimal numbers (up to 38 digits with nine decimal places). But Snaps in Google BigQuery Snap Pack that load data into tables cannot create numeric columns. When the Create table if not present check box is selected, the Snaps create the required table schema, but map big decimals to a FLOAT64 column. So, to store the data into numeric columns using these Snaps, we recommend the following actions:

  • Create the required schema, beforehand, with numeric columns in Google BigQuery.
  • Pass the number as a string.

The Google API converts this string into a number with full precision and saves it in the numeric column.

Example

Value Passed Through SnapValue Stored in BigQueryRemarks
"12345678901234567890123456789.123456789"12345678901234567890123456789.123456789As per this issue logged in Google Issue Tracker, if you send the values as strings, the values are never converted to floating-point form, so this works as expected.
12345678901234567890123456789.123456789123456789012345678000000000000Big decimal values sent as non-string values lose precision.


 Example



The sample pipeline is as shown below that writes data into a BigQuery table.

 


The input record is passed from the JSON Generator. Its contents are shown below.

The BigQuery Write Snap with Project ID, Dataset ID and Table ID completed is shown as below.

The number of records inserted into the BigQuery table are shown in the output view.


Insert excerpt
Google BigQuery Snap Pack
Google BigQuery Snap Pack
nopaneltrue