August 17, 2023

tELTHiveMap – Docs for ESB 5.x

tELTHiveMap

telthivemap_icon32_white.png

tELTHiveMap properties

The three ELT Hive components are closely related, in terms of their operating
conditions. These components should be used to handle Hive DB schemas to generate Insert
statements, including clauses, which are to be executed in the DB output table
defined.

Component family

ELT/Map/Hive

 

Function

This component uses the tables provided as input, to feed the
parameter in the built statement. The statement can include inner or
outer joins to be implemented between tables or between one table
and its aliases.

Purpose

This component helps to graphically build the Hive QL statement in
order to transform data.

 Basic settings

Property type

Either Built-in or Repository.

 

 

Built-in: No property data is
stored centrally.

 

 

Repository: Select the repository
file in which the properties are stored. The fields that follow are
completed automatically using the data retrieved.

 

Use an existing connection

Select this check box and in the Component List click the
relevant connection component to reuse the connection details you already defined.

Note

When a Job contains the parent Job and the child Job, if you need to share an existing
connection between the two levels, for example, to share the connection created by the
parent Job with the child Job, you have to:

  1. In the parent level, register the database connection to be shared in the
    Basic settings view of the connection
    component which creates that very database connection.

  2. In the child level, use a dedicated connection component to read that
    registered database connection.

For an example about how to share a database connection across Job levels, see
Talend Studio User
Guide
.

 

ELT Hive Map editor

The ELT Map editor helps you to define the output schema as well
as build graphically the Hive QL statement to be executed. The
column names of schema can be different from the column names in the
database.

 

Style link

Select the way in which links are displayed.

Auto: By default, the links between
the input and output schemas and the Web service parameters are in
the form of curves.

Bezier curve: Links between the
schema and the Web service parameters are in the form of curve.

Line: Links between the schema and
the Web service parameters are in the form of straight lines.

This option slightly optimizes performance.

Version

Distribution

Select the cluster you are using from the drop-down list. The options in the list vary
depending on the component you are using. Among these options, the following ones requires
specific configuration:

  • If available in this Distribution drop-down list, the
    Microsoft HD Insight option allows you to use a
    Microsoft HD Insight cluster. For this purpose, you need to configure the
    connections to the WebHCat service, the HD Insight service and the Windows Azure
    Storage service of that cluster in the areas that are displayed. A demonstration
    video about how to configure this connection is available in the following link:
    https://www.youtube.com/watch?v=A3QTT6VsNoM

  • The Custom option allows you to connect to a
    cluster different from any of the distributions given in this list, that is to
    say, to connect to a cluster not officially supported by Talend.

In order to connect to a custom distribution, once selecting Custom, click the dotbutton.png button to display the dialog box in which you can
alternatively:

  1. Select Import from existing version to import an
    officially supported distribution as base and then add other required jar files
    which the base distribution does not provide.

  2. Select Import from zip to import a custom
    distribution zip that, for example, you can download from http://www.talendforge.org/exchange/index.php.

    Note

    In this dialog box, the active check box must be kept selected so as to import
    the jar files pertinent to the connection to be created between the custom
    distribution and this component.

    For an step-by-step example about how to connect to a custom distribution and
    share this connection, see Connecting to a custom Hadoop distribution.

 

Hive version

Select the version of the Hadoop distribution you are using. The available options vary
depending on the component you are using. Along with the evolution of Hadoop, please note
the following changes:

  • If you use Hortonworks Data Platform V2.2, the
    configuration files of your cluster might be using environment variables such as
    ${hdp.version}. If this is your situation, you
    need to set the mapreduce.application.framework.path property in the Hadoop properties table of this component with the path value
    explicitly pointing to the MapReduce framework archive of your cluster. For
    example:

  • If you use Hortonworks Data Platform V2.0.0, the
    type of the operating system for running the distribution and a Talend
    Job must be the same, such as Windows or Linux. Otherwise, you have to use Talend
    Jobserver to execute the Job in the same type of operating system in which the
    Hortonworks Data Platform V2.0.0 distribution you
    are using is run. For further information about Talend Jobserver, see
    Talend Installation
    and Upgrade Guide
    .

 

Hive server

Select the Hive server through which you want the Job using this component to execute
queries on Hive.

This Hive server list is available only when the Hadoop
distribution to be used such as HortonWorks Data Platform V1.2.0
(Bimota)
supports HiveServer2. It allows you to select HiveServer2 (Hive 2), the server that better support concurrent connections of
multiple clients than HiveServer (Hive 1).

For further information about HiveServer2, see https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2.

 

Connection mode

Select a connection mode from the list. The options vary depending
on the distribution you are using.

 

Host

Database server IP address.

 

Port

Listening port number of DB server.

 

Database

Name of the database. According to the documentation of Hive, the
only database name supported is default.

For further information, see https://cwiki.apache.org/confluence/display/Hive/HiveClient.

 

Username and
Password

DB user authentication data.

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

Authentication

Use kerberos authentication

If you are accessing a Hive Metastore running with Kerberos security, select this check
box and then enter the relevant parameters in the fields that appear.

The values of the following parameters can be found in the hive-site.xml file of the Hive system to be used.

  1. Hive principal uses the value of hive.metastore.kerberos.principal. This is the
    service principal of the Hive Metastore.

  2. Metastore URL uses the value of javax.jdo.option.ConnectionURL. This is the JDBC
    connection string to the Hive Metastore.

  3. Driver class uses the value of javax.jdo.option.ConnectionDriverName. This is the
    name of the driver for the JDBC connection.

  4. Username uses the value of javax.jdo.option.ConnectionUserName. This, as well
    as the Password parameter, is the user credential for connecting to the Hive
    Metastore.

  5. Password uses the value of javax.jdo.option.ConnectionPassword.

For the other parameters that are displayed, please consult the Hadoop
configuration files they belong to. For example, the Namenode
principal
can be found in the hdfs-site.xml file or the hdfs-default.xml file of the distribution you are using.

This check box is available depending on the Hadoop distribution you are connecting
to.

  Use a keytab to authenticate

Select the Use a keytab to authenticate check box to log
into a Kerberos-enabled Hadoop system using a given keytab file. A keytab file contains
pairs of Kerberos principals and encrypted keys. You need to enter the principal to be used
in the Principal field and the access path to the keytab
file itself in the Keytab field.

Note that the user that executes a keytab-enabled Job is not necessarily the one a
principal designates but must have the right to read the keytab file being used. For
example, the user name you are using to execute a Job is user1 and the principal to be used is guest; in this situation, ensure that user1 has the right to read the keytab file to be used.

Hadoop properties

Set Jobtracker URI

Select this check box to indicate the location of the Jobtracker service within the Hadoop
cluster to be used. For example, we assume that you have chosen a machine called machine1 as the JobTracker, then set its location as machine1:portnumber. A Jobtracker is the service that assigns
Map/Reduce tasks to specific nodes in a Hadoop cluster. Note that the notion job in this
term JobTracker does not designate a Talend Job, but rather a Hadoop job
described as MR or MapReduce job in Apache’s Hadoop documentation on http://hadoop.apache.org.

This property is required when the query you want to use is executed in Windows and it is
a Select query. For example, SELECT your_column_name FROM
your_table_name

If you use YARN in your Hadoop cluster such as Hortonworks Data
Platform V2.0.0
or Cloudera CDH4.3 + (YARN
mode)
, you need to specify the location of the Resource
Manager
instead of the Jobtracker. Then you can continue to set the following
parameters depending on the configuration of the Hadoop cluster to be used (if you leave the
check box of a parameter clear, then at runtime, the configuration about this parameter in
the Hadoop cluster to be used will be ignored ):

  1. Select the Set resourcemanager scheduler
    address
    check box and enter the Scheduler address in the field
    that appears.

  2. Allocate proper memory volumes to the Map and
    the Reduce computations and the ApplicationMaster of YARN by selecting the Set memory check box in the Advanced settings view.

  3. Select the Set jobhistory address check box
    and enter the location of the JobHistory server of the Hadoop cluster to be
    used. This allows the metrics information of the current Job to be stored in
    that JobHistory server.

  4. Select the Set staging directory check box
    and enter this directory defined in your Hadoop cluster for temporary files
    created by running programs. Typically, this directory can be found under the
    yarn.app.mapreduce.am.staging-dir
    property in the configuration files such as yarn-site.xml or mapred-site.xml of your distribution.

  5. Select the Set Hadoop user check box and
    enter the user name under which you want to execute the Job. Since a file or a
    directory in Hadoop has its specific owner with appropriate read or write
    rights, this field allows you to execute the Job directly under the user name
    that has the appropriate rights to access the file or directory to be
    processed.

  6. Select the Use datanode hostname check box to
    allow the Job to access datanodes via their hostnames. This actually sets the
    dfs.client.use.datanode.hostname property
    to true.

For further information about these parameters, see the documentation or
contact the administrator of the Hadoop cluster to be used.

For further information about the Hadoop Map/Reduce framework, see the Map/Reduce tutorial
in Apache’s Hadoop documentation on http://hadoop.apache.org.

 

Set NameNode URI

Select this check box to indicate the location of the NameNode of the Hadoop cluster to be
used. The NameNode is the master node of a Hadoop cluster. For example, we assume that you
have chosen a machine called masternode as the NameNode
of an Apache Hadoop distribution, then the location is hdfs://masternode:portnumber.

This property is required when the query you want to use is executed in Windows and it is
a Select query. For example, SELECT your_column_name FROM
your_table_name

For further information about the Hadoop Map/Reduce framework, see the Map/Reduce tutorial
in Apache’s Hadoop documentation on http://hadoop.apache.org.

Advanced settings

Temporary path

If you do not want to set the Jobtracker and the NameNode when you execute the query
select * from your_table_name, you need to set this temporary path. For
example, /C:/select_all in Windows.

Hadoop properties

Talend Studio uses a default configuration for its engine to perform
operations in a Hadoop distribution. If you need to use a custom configuration in a specific
situation, complete this table with the property or properties to be customized. Then at
runtime, the customized property or properties will override those default ones.

  • Note that if you are using the centrally stored metadata from the Repository, this table automatically inherits the
    properties defined in that metadata and becomes uneditable unless you change the
    Property type from Repository to Built-in.

For further information about the properties required by Hadoop and its related systems such
as HDFS and Hive, see the documentation of the Hadoop distribution you
are using or see Apache’s Hadoop documentation on http://hadoop.apache.org/docs and then select the version of the documentation you want. For demonstration purposes, the links to some properties are listed below:

 

Hive properties

Talend Studio uses a default
configuration for its engine to perform operations in a Hive database. If you need to use a
custom configuration in a specific situation, complete this table with the property or
properties to be customized. Then at runtime, the customized property or properties will
override those default ones. For further information for Hive dedicated properties, see
https://cwiki.apache.org/confluence/display/Hive/AdminManual+Configuration.

  • Note that if you are using the centrally stored metadata from the Repository, this table automatically inherits the
    properties defined in that metadata and becomes uneditable unless you change the
    Property type from Repository to Built-in.

 

Mapred job map memory mb and
Mapred job reduce memory
mb

If the Hadoop distribution to be used is Hortonworks Data Platform V1.2 or Hortonworks
Data Platform V1.3, you need to set proper memory allocations for the map and reduce
computations to be performed by the Hadoop system.

In that situation, you need to enter the values you need in the Mapred
job map memory mb
and the Mapred job reduce memory
mb
fields, respectively. By default, the values are both 1000 which are normally appropriate for running the
computations.

 

Path separator in server

Leave the default value of the Path separator in server as
it is, unless you have changed the separator used by your Hadoop distribution’s host machine
for its PATH variable or in other words, that separator is not a colon (:). In that
situation, you must change this value to the one you are using in that host.

 

tStatCatcher Statistics

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

 

Temporary path

If you do not want to set the Jobtracker and the NameNode when you execute the query
select * from your_table_name, you need to set this temporary path. For
example, /C:/select_all in Windows.

Dynamic settings

Click the [+] button to add a row in the table and fill
the Code field with a context variable to choose your
database connection dynamically from multiple connections planned in your Job. This feature
is useful when you need to access database tables having the same data structure but in
different databases, especially when you are working in an environment where you cannot
change your Job settings, for example, when your Job has to be deployed and executed
independent of Talend Studio.

The Dynamic settings table is available only when the
Use an existing connection check box is selected in the
Basic settings view. Once a dynamic parameter is
defined, the Component List box in the Basic settings view becomes unusable.

For more information on Dynamic settings and context
variables, see Talend Studio User Guide.

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

tELTHiveMap is used along with a
tELTHiveInput and tELTHiveOutput. Note that the Output link
to be used with these components must correspond strictly to the
syntax of the table name.

If the Studio used to connect to a Hive database is operated on Windows, you must manually
create a folder called tmp in the root of the disk where
this Studio is installed.

Note

The ELT components do not handle actual data flow but only
schema information.

Prerequisites

The Hadoop distribution must be properly installed, so as to guarantee the interaction
with Talend Studio. The following list presents MapR related information for
example.

  • Ensure that you have installed the MapR client in the machine where the Studio is,
    and added the MapR client library to the PATH variable of that machine. According
    to MapR’s documentation, the library or libraries of a MapR client corresponding to
    each OS version can be found under MAPR_INSTALL
    hadoophadoop-VERSIONlib
    ative
    . For example, the library for
    Windows is lib
    ativeMapRClient.dll
    in the MapR
    client jar file. For further information, see the following link from MapR: http://www.mapr.com/blog/basic-notes-on-configuring-eclipse-as-a-hadoop-development-environment-for-mapr.

    Without adding the specified library or libraries, you may encounter the following
    error: no MapRClient in java.library.path.

  • Set the -Djava.library.path argument, for example, in the Job Run VM arguments area
    of the Run/Debug view in the [Preferences] dialog box. This argument provides to the Studio the
    path to the native library of that MapR client. This allows the subscription-based
    users to make full use of the Data viewer to view
    locally in the Studio the data stored in MapR. For further information about how to
    set this argument, see the section describing how to view data of Talend Big Data Getting Started Guide.

For further information about how to install a Hadoop distribution, see the manuals
corresponding to the Hadoop distribution you are using.

Connecting Hive ELT components

The ELT components do not handle any data as such but table schema information
that will be used to build the Hive QL query to execute.

Therefore the only connection required to connect these components together is a
simple link.

Note

The output name you give to this link when creating it should always be the
exact name of the table to be accessed as this parameter will be used in the
Hive QL statement generated.

Related topic: see Talend Studio User
Guide
.

Mapping and joining tables

In the ELT Mapper, you can select specific columns from input schemas and include
them in the output schema.

  • As you would do it in the regular Map editor, simply drag & drop the
    content from the input schema towards the output table defined.

  • Use the Ctrl and Shift keys for multiple selection of contiguous or non
    contiguous table columns.

You can implement explicit joins to retrieve various data from different tables.

  • Select the Explicit join check box for
    the relevant column, and select a type of join from the Join list.

  • Possible joins include: Join (Inner
    Join), Left Outer Join, Right Outer Join or Full
    Outer Join
    and Left Semi
    Join
    .

  • By default the Join option is
    selected.

You can also create Alias tables to retrieve
various data from the same table.

  • In the Input area, click the Button_Plus.png button to create an Alias.

  • Define the table to base the alias on.

  • Type in a new name for the alias table, preferably not the same as the
    main table.

Adding where and other clauses

You can also restrict the Select statement based on a Where clause and/or other clauses such
as Group By, Order By, etc. by clicking the Add filter
row
button at the top of the output table in the map editor.

To add a restriction based on a Where clause, click the Add
filter row
button and select Add a WHERE
clause
from the popup menu.

To add a restriction based on Group By, Order By etc., click the Add filter row button and select Add an
other(GROUP…) clause
from the popup menu.

components-teltmysqlmap_add_clauses.png

Make sure that all input components are linked correctly to the ELT Map component to
be able to implement all inclusions, joins and clauses.

Generating the Hive QL statement

The mapping of elements from the input schemas to the output schemas create
instantly the corresponding Select statement. For example,

use_case-telthivemap2.png

The clause are also included automatically.

Scenario: Joining table columns and writing them into Hive

This scenario uses a four-component Job to join the columns selected from two Hive
tables and write them into another Hive table.

use_case-telthivemap1.png

Preparing the Hive tables

  1. Create the Hive table you want to write data in. In this scenario, this
    table is named as agg_result, and you can
    create it using the following statement in tHiveRow:

    In this statement,
    ‘/user/ychen/hive/table/agg_result’
    is the directory used in
    this scenario to store this created table in HDFS. You need to replace it
    with the directory you want to use in your environment.

    For further information about tHiveRow,
    see tHiveRow.

  2. Create two input Hive tables containing the columns you want to join and
    aggregate these columns into the output Hive table, agg_result. The statements to be used are:

    and

  3. Use tHiveRow to load data into the two
    input tables, customer and state_city. The statements to be used are:

    and

    The two files, customer.csv and
    State_City.csv, are two local files
    we created for this scenario. You need to create your own files to provide
    data to the input Hive tables. The data schema of each file should be
    identical with their corresponding table.

    You can use tRowGenerator and tFileOutputDelimited to create these two files
    easily. For further information about these two components, see tRowGenerator and tFileOutputDelimited.

    For further information about the Hive query language, see https://cwiki.apache.org/confluence/display/Hive/LanguageManual.

Linking the components

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

    For further information about how to create a Job, see Talend Studio User Guide.

  2. Drop two tELTHiveInput components and
    tELTHiveMap and tELTHiveOutput onto the workspace.

  3. Connect them using the Row > Main
    link.

    Each time when you connect two components, a wizard pops up to prompt you
    to name the link you are creating. This name must be the same as that of the
    Hive table you want the active component to process. In this scenario, the
    input tables the two tELTHiveInput
    components will handle are customer and
    state_city and the output table
    tELTHiveOutput will handle is agg_result.

Configuring the input schemas

  1. Double-click the tELTHiveInput component
    using the customer link to open its
    Component view.

    use_case-telthivemap3.png
  2. Click the […] button next to Edit schema to open the schema editor.

  3. Click the Button_Plus.png button as many times as required to add columns and
    rename them to replicate the schema of the customer table we created earlier in Hive.

    use_case-telthivemap4.png

    To set up this schema, you can as well use the
    customer schema you retrieve and
    store in the Repository. For further
    information about how to set up a connection to Hive and retrieve and store
    the schema in Repository, see Talend Studio User Guide.

  4. In the Default table name field, enter
    the name of the input table, customer, to
    be processed by this component.

  5. Double-click the other tELTHiveInput
    component using the state_city link to
    open its Component view.

    use_case-telthivemap10.png
  6. Click the […] button next to Edit schema to open the schema editor.

  7. Click the Button_Plus.png button as many times as required to add columns and
    rename them to replicate the schema of the state_city table we created earlier in Hive.

    use_case-telthivemap5.png
  8. In the Default table name field, enter
    the name of the input table, state_city,
    to be processed by this component.

Mapping the input and the output schemas

Configuring the connection to Hive

  1. Click tELTHiveMap, then, click Component to open its Component view.

    use_case-telthivemap6.png
  2. In the Version area, select the Hadoop
    distribution you are using and the Hive version.

  3. In the Connection mode list, select the
    connection mode you want to use. If your distribution is HortonWorks, this
    mode is Embedded only.

  4. In the Host field and the Port field, enter the authentication information
    for the component to connect to Hive. For example, the host is talend-hdp-all and the port is 9083.

  5. Select the Set Jobtracker URI check box
    and enter the location of the Jobtracker. For example, talend-hdp-all:50300.

  6. Select the Set NameNode URI check box and
    enter the location of the NameNode. For example, hdfs://talend-hdp-all:8020.

Mapping the schemas

  1. Click ELT Hive Map Editor to map the
    schemas

    use_case-telthivemap7.png
  2. On the input side (left in the figure), click the Add alias button to add the table to be used.

    add_alias.png
  3. In the pop-up window, select the customer table, then click OK.

  4. Repeat the operations to select the state_city table.

  5. Drag and drop the idstate column from
    the customer table onto the id column of the state_city table. Thus an inner join is created
    automatically.

  6. On the output side (the right side in the figure), the agg_result table is empty at first. Click Button_Plus.png at the bottom of this side to add as many columns as
    required and rename them to replicate the schema of the agg_result table you created earlier in Hive.

    use_case-telthivemap8.png

    Note

    The type column is the partition
    column of the agg_result table and
    should not be replicated in this schema. For further information about
    the partition column of the Hive table, see the Hive manual.

  7. From the customer table, drop id, name,
    address, and sum1 to the corresponding columns in the agg_result table.

  8. From the state_city table, drop
    postal, state, capital and
    mostpopulouscity to the corresponding
    columns in the agg_result table.

  9. Click OK to validate these
    changes.

Configuring the output schema

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

    use_case-telthivemap9.png
  2. If this component does not have the same schema of the preceding
    component, a warning icon appears. In this case, click the Sync columns button to retrieve the schema from
    the preceding one and once done, the warning icon disappears.

  3. In the Default table name field, enter
    the output table you want to write data in. In this example, it is agg_result.

  4. In the Field partition table, click Button_Plus.png to add one row. This allows you to write data in the
    partition column of the agg_result
    table.

    This partition column was defined the moment we created the agg_result table using partitioned by
    (type string)
    in the Create statement presented earlier. This
    partition column is type, which describes
    the type of a customer.

  5. In Partition column, enter type without any quotation marks and in
    Partition value, enter prospective in single quotation marks.

Executing the Job

  • Press F6 to run this Job.

Once done, verify agg_result in Hive using, for
example,

use_case-telthivemap11.png

This figure present only a part of the table. You can find that the selected input
columns are aggregated and written into the
agg_result
table and the partition column is filled with the value
prospective.

Related scenario

For a related scenario using subquery, see Scenario: Mapping data using a subquery.


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