July 30, 2023

tBigQueryInput – Docs for ESB 7.x

tBigQueryInput

Performs the queries supported by Google BigQuery.

This component connects to Google BigQuery and performs queries in
it.

tBigQueryInput Standard properties

These properties are used to configure tBigQueryInput running in the Standard Job framework.

The Standard
tBigQueryInput component belongs to the Big Data family.

The component in this framework is available in all Talend
products
.

Basic settings

Schema and Edit schema

A schema is a row description. It defines the number of fields
(columns) to be processed and passed on to the next component. When you create a Spark
Job, avoid the reserved word line when naming the
fields.

  • Built-In: You create and store the schema locally for this component
    only.

  • Repository: You have already created the schema and stored it in the
    Repository. You can reuse it in various projects and Job designs.

Click Edit
schema
to make changes to the schema.

Note: If you
make changes, the schema automatically becomes built-in.
  • View schema: choose this
    option to view the schema only.

  • Change to built-in property:
    choose this option to change the schema to Built-in for local changes.

  • Update repository connection:
    choose this option to change the schema stored in the repository and decide whether
    to propagate the changes to all the Jobs upon completion. If you just want to
    propagate the changes to the current Job, you can select No upon completion and choose this schema metadata
    again in the Repository Content
    window.

This
component offers the advantage of the dynamic schema feature. This allows you to
retrieve unknown columns from source files or to copy batches of columns from a source
without mapping each column individually. For further information about dynamic schemas,
see
Talend Studio

User Guide.

This
dynamic schema feature is designed for the purpose of retrieving unknown columns of a
table and is recommended to be used for this purpose only; it is not recommended for the
use of creating tables.

 
  • The Record type of BigQuery is not supported.
  • The columns for table metadata such as the Description column or the Mode column cannot be retrieved.
  • The Timestamp data from your BigQuery system is formated to be
    String data.
  • The numeric data of BigQuery is converted to BigDecimal.
Authentication mode Select the mode to be used to authenticate to your project.

  • OAuth 2.0: authenticate the access using
    OAuth credentials. When selecting this mode, the parameters to be
    defined in the Basic settings view are
    Client ID, Client
    secret
    and Authorization
    code
    .
  • Service account: authenticate using a Google
    account that is associated with your Google Cloud Platform project.
    When selecting this mode, the parameter to be defined in the
    Basic settings view is Service
    account credentials file
    .
Service account credentials file Enter the path to the credentials file created for the service account
to be used. This file must be stored in the machine in which your Talend Job is actually launched and
executed.

For further information about how to create a Google service
account and obtain the credentials file, see Getting Started with
Authentication
from the Google documentation.

Client ID and Client
secret

Paste the client ID and the client secret, both created and viewable on the
API Access tab view of the project hosting the Google BigQuery service and the Cloud
Storage service you need to use.

To enter the client secret, click the […] button next
to the client secret field, and then in the pop-up dialog box enter the client secret
between double quotes and click OK to save the
settings.

Project ID

Paste the ID of the project hosting the Google BigQuery service you
need to use.

The ID of your project can be found in the URL of the Google
API Console, or by hovering your mouse pointer over the name of the
project in the BigQuery Browser Tool.

Authorization code

Paste the authorization code provided by Google for the access you are
building.

To obtain the authorization code, you need to execute the Job using this
component and when this Job pauses execution to print out an URL address, you
navigate to this address to copy the authorization code displayed.

Use legacy SQL and Query

Enter the query you need to use.

If the query to be used is the
legacy SQL of BigQuery, select this Use legacy
SQL
check box. For further information about this legacy
SQL, see Legacy SQL query reference
from the Google BigQuery documentation.

Result size

Select the option depending on the volume of the query result.

By default, the Small option is used, but when the
query result is larger than the maximum response size, you
need to select the Large option.

If the volume of the result is not certain, select
Auto.

Advanced settings

token properties File Name

Enter the path to, or browse to the refresh token file you need to use.

At the first Job execution using the Authorization
code
you have obtained from Google BigQuery, the value in this field
is the directory and the name of that refresh token file to be created and used; if
that token file has been created and you need to reuse it, you have to specify its
directory and file name in this field.

With only the token file name entered,
Talend Studio
considers the directory of that token file to be the root of the Studio
folder.

For further information about the refresh token, see the manual of Google
BigQuery.

Advanced Separator (for number)

Select this check box to change the separator used for the
numbers.

Encoding

Select the encoding from the list or select Custom
and define it manually. This field is compulsory for database data handling. The
supported encodings depend on the JVM that you are using. For more information, see
https://docs.oracle.com.

Use custom temporary Dataset name

Select this check box to use an existing dataset to which you have
access, instead of creating one, and in the field that is displayed,
enter the name of this dataset. This way, you avoid rights and
permissions issues related to dataset creation.

This check box is available only when you have selected
Large from the Result
size
drop-down list in the Basic
settings
tab.

tStatCatcher Statistics

Select this check box to collect the log data at the component
level.

Global Variables

Global Variables

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see
Talend Studio

User Guide.

Usage

Usage rule

This is an input component. It sends the extracted data to the component
that follows it.

This component automatically detects and
supports both multi-regional locations and regional locations. When using the
regional locations, the buckets and the datasets to be used must be in the same
locations.

Performing a query in Google BigQuery

This scenario uses two components to perform the SELECT query in BigQuery and present
the result in the Studio.

tBigQueryInput_1.png

The following figure shows the schema of the table, UScustomer, we use as example to perform the SELECT query in.

tBigQueryInput_2.png

We will select the State records and count the occurrence of each State among those
records.

Linking the components

  1. In the
    Integration
    perspective
    of Studio, create an empty Job, named BigQueryInput for example, from the
    Job Designs
    node in the Repository tree view.

    For further information about how to create a Job, see the
    Talend Studio
    User
    Guide.
  2. Drop tBigQueryInput and tLogRow onto the workspace.
  3. Connect them using the Row > Main
    link.

Creating the query

Building access to BigQuery

  1. Double-click tBigQueryInput to open its
    Component view.

    tBigQueryInput_3.png

  2. Click Edit schema to open the
    editor

    tBigQueryInput_4.png

  3. Click the

    tBigQueryInput_5.png

    button twice to add two rows and enter the names of
    your choice for each of them in the Column
    column. In this scenario, they are: States and Count.

  4. Click OK to validate these changes and
    accept the propagation prompted by the pop-up dialog box.
  5. In the Authentication area, add the authentication
    information. In most cases, the Service account mode is more
    straight-forward and easy to handle.

    Authentication mode Description
    Service account Authenticate using a Google account that is associated with your Google
    Cloud Platform project.

    When selecting this mode, the Service
    account credentials file
    field is displayed. In this field,
    enter the path to the credentials file created for the service account to be
    used. This file must be stored in the machine in which your Talend Job is actually
    launched and executed.

    For further information about how to create a
    Google service account and obtain the credentials file, see Getting Started with Authentication
    from the Google documentation.

    OAuth 2.0 Authenticate the access using OAuth credentials. When selecting this mode,
    the parameters to be defined in the Basic settings view
    are Client ID, Client secret and
    Authorization code.

    1. Navigate to the Google APIs Console in your web browser to access the
      Google project hosting the BigQuery and the Cloud Storage services you
      need to use.
    2. Click the API Access tab to open its view. and copy Client ID, Client
      secret and Project ID.
    3. In the Component view of the Studio, paste Client
      ID, Client secret and Project ID from the API Access tab view to the
      corresponding fields, respectively.
    4. In the Run view of the Studio,
      click Run to execute this Job. The
      execution will pause at a given moment to print out in the console the
      URL address used to get the authorization code.
    5. Navigate to this address in your web browser and copy the authorization
      code displayed.
    6. In the Component view of tBigQueryOutput, paste the authorization
      code in the Authorization Code
      field.

Writing the query

In the Query field, enter

select States, count (*) as Count from documentation.UScustomer group by States

Executing the Job

The tLogRow component presents the execution
result of the Job. You can configure the presentation mode on its Component view.

To do this, double-click tLogRow to open the
Component view and in the Mode area, select the Table (print values in
cells of a table)
option.

To execute this Job, press F6.

Once done, the Run view is opened automatically,
where you can check the execution result.

tBigQueryInput_6.png

tBigQueryInput properties for Apache Spark Batch

These properties are used to configure tBigQueryInput running in the Spark Batch Job framework.

The Spark Batch
tBigQueryInput component belongs to the Databases family.

The component in this framework is available in all subscription-based Talend products with Big Data
and Talend Data Fabric.

Basic settings

Source type

Select the way you want tBigQueryInput to read data
from Google BigQuery:

  • Table: copy the whole table.

  • Query: write a query to select
    data.

Schema and Edit Schema

A schema is a row description. It defines the number of fields
(columns) to be processed and passed on to the next component. When you create a Spark
Job, avoid the reserved word line when naming the
fields.

Click Edit
schema
to make changes to the schema. If the current schema is of the Repository type, three options are available:

  • View schema: choose this
    option to view the schema only.

  • Change to built-in property:
    choose this option to change the schema to Built-in for local changes.

  • Update repository connection:
    choose this option to change the schema stored in the repository and decide whether
    to propagate the changes to all the Jobs upon completion. If you just want to
    propagate the changes to the current Job, you can select No upon completion and choose this schema metadata
    again in the Repository Content
    window.

 

Built-In: You create and store the schema locally for this component
only.

 

Repository: You have already created the schema and stored it in the
Repository. You can reuse it in various projects and Job designs.

When the Source type is Table:

Project ID

If your Google BigQuery service uses the
Google Cloud Platform project ID, keep this check box clear to allow
tBigQueryInput to read this ID from the
Spark configuration tab or the
tBigQueryConfiguration component.

If the Google BigQuery service uses
a custom ID, select this check box and enter the ID.

The ID of your project can be found in the URL of the Google
API Console, or by hovering your mouse pointer over the name of the
project in the BigQuery Browser Tool.

Dataset

Enter the name of the dataset to which the table to be copied
belongs.

When you use Google BigQuery with Dataproc, in
Google Cloud Platform, select the same region for your BigQuery dataset
as for the Dataproc cluster to be run.

Table

Enter the name of the table to be copied.

When the Source type is Query:

Query

Enter the query to be used.

When you use Google BigQuery with Dataproc, in
Google Cloud Platform, select the same region for your BigQuery dataset
as for the Dataproc cluster to be run.

If the query to be used is the
legacy SQL of BigQuery, select this Use legacy
SQL
check box. For further information about this legacy
SQL, see Legacy SQL query reference
from the Google BigQuery documentation.

Usage

Usage rule

This is an input component. It sends data extracted from
BigQuery to the component that follows it.

Place a
tBigQueryConfiguration component in the same Job
because it needs to use the BigQuery configuration information provided
by tBigQueryConfiguration.

Spark Connection

In the Spark
Configuration
tab in the Run
view, define the connection to a given Spark cluster for the whole Job. In
addition, since the Job expects its dependent jar files for execution, you must
specify the directory in the file system to which these jar files are
transferred so that Spark can access these files:

  • Yarn mode (Yarn client or Yarn cluster):

    • When using Google Dataproc, specify a bucket in the
      Google Storage staging bucket
      field in the Spark configuration
      tab.

    • When using HDInsight, specify the blob to be used for Job
      deployment in the Windows Azure Storage
      configuration
      area in the Spark
      configuration
      tab.

    • When using Altus, specify the S3 bucket or the Azure
      Data Lake Storage for Job deployment in the Spark
      configuration
      tab.
    • When using Qubole, add a
      tS3Configuration to your Job to write
      your actual business data in the S3 system with Qubole. Without
      tS3Configuration, this business data is
      written in the Qubole HDFS system and destroyed once you shut
      down your cluster.
    • When using on-premise
      distributions, use the configuration component corresponding
      to the file system your cluster is using. Typically, this
      system is HDFS and so use tHDFSConfiguration.

  • Standalone mode: use the
    configuration component corresponding to the file system your cluster is
    using, such as tHDFSConfiguration or
    tS3Configuration.

    If you are using Databricks without any configuration component present
    in your Job, your business data is written directly in DBFS (Databricks
    Filesystem).

This connection is effective on a per-Job basis.

tBigQueryInput properties for Apache Spark Streaming

These properties are used to configure tBigQueryInput running in the Spark Streaming Job framework.

The Spark Streaming
tBigQueryInput component belongs to the Databases family.

This component is available in Talend Real Time Big Data Platform and Talend Data Fabric.

Basic settings

Source type

Select the way you want tBigQueryInput to read data
from Google BigQuery:

  • Table: copy the whole table.

  • Query: write a query to select
    data.

Schema and Edit Schema

A schema is a row description. It defines the number of fields
(columns) to be processed and passed on to the next component. When you create a Spark
Job, avoid the reserved word line when naming the
fields.

Click Edit
schema
to make changes to the schema. If the current schema is of the Repository type, three options are available:

  • View schema: choose this
    option to view the schema only.

  • Change to built-in property:
    choose this option to change the schema to Built-in for local changes.

  • Update repository connection:
    choose this option to change the schema stored in the repository and decide whether
    to propagate the changes to all the Jobs upon completion. If you just want to
    propagate the changes to the current Job, you can select No upon completion and choose this schema metadata
    again in the Repository Content
    window.

 

Built-In: You create and store the schema locally for this component
only.

 

Repository: You have already created the schema and stored it in the
Repository. You can reuse it in various projects and Job designs.

When the Source type is Table:

Project ID

If your Google BigQuery service uses the
Google Cloud Platform project ID, keep this check box clear to allow
tBigQueryInput to read this ID from the
Spark configuration tab or the
tBigQueryConfiguration component.

If the Google BigQuery service uses
a custom ID, select this check box and enter the ID.

The ID of your project can be found in the URL of the Google
API Console, or by hovering your mouse pointer over the name of the
project in the BigQuery Browser Tool.

Dataset

Enter the name of the dataset to which the table to be copied
belongs.

When you use Google BigQuery with Dataproc, in
Google Cloud Platform, select the same region for your BigQuery dataset
as for the Dataproc cluster to be run.

Table

Enter the name of the table to be copied.

When the Source type is Query:

Query

Enter the query to be used.

When you use Google BigQuery with Dataproc, in
Google Cloud Platform, select the same region for your BigQuery dataset
as for the Dataproc cluster to be run.

If the query to be used is the
legacy SQL of BigQuery, select this Use legacy
SQL
check box. For further information about this legacy
SQL, see Legacy SQL query reference
from the Google BigQuery documentation.

Usage

Usage rule

This is an input component. It sends data extracted from
BigQuery to the component that follows it.

Place a
tBigQueryConfiguration component in the same Job
because it needs to use the BigQuery configuration information provided
by tBigQueryConfiguration.

Spark Connection

In the Spark
Configuration
tab in the Run
view, define the connection to a given Spark cluster for the whole Job. In
addition, since the Job expects its dependent jar files for execution, you must
specify the directory in the file system to which these jar files are
transferred so that Spark can access these files:

  • Yarn mode (Yarn client or Yarn cluster):

    • When using Google Dataproc, specify a bucket in the
      Google Storage staging bucket
      field in the Spark configuration
      tab.

    • When using HDInsight, specify the blob to be used for Job
      deployment in the Windows Azure Storage
      configuration
      area in the Spark
      configuration
      tab.

    • When using Altus, specify the S3 bucket or the Azure
      Data Lake Storage for Job deployment in the Spark
      configuration
      tab.
    • When using Qubole, add a
      tS3Configuration to your Job to write
      your actual business data in the S3 system with Qubole. Without
      tS3Configuration, this business data is
      written in the Qubole HDFS system and destroyed once you shut
      down your cluster.
    • When using on-premise
      distributions, use the configuration component corresponding
      to the file system your cluster is using. Typically, this
      system is HDFS and so use tHDFSConfiguration.

  • Standalone mode: use the
    configuration component corresponding to the file system your cluster is
    using, such as tHDFSConfiguration or
    tS3Configuration.

    If you are using Databricks without any configuration component present
    in your Job, your business data is written directly in DBFS (Databricks
    Filesystem).

This connection is effective on a per-Job basis.


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x