tNeo4jRow - 6.3

Talend Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

Warning

This component is available in the Palette of the studio only if you have subscribed to one of the Talend solutions with Big Data.

Function

tNeo4jRow is the specific component for this database query. It executes the stated Cypher query onto the specified database. The row suffix means the component implements a flow in the Job design although it doesn't provide output.

Purpose

Depending on the nature of the query, tNeo4jRow acts on the data (although without handling data).

tNeo4jRow properties

Component family

Big Data / Neo4j

 

Basic settings

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.

 

DB version

Select the Neo4j version you are using, between Neo4J 1.X.X and Neo4J 2.X.X.

Note that Neo4j version 2.X.X is compatible only with Java 7 or higher but it offers support of advanced features such as node labels.

This list is not shown if the Use an existing connection check box is selected.

Upon selecting a database version, you will be prompted to install the corresponding database driver JAR files if not yet installed. For more information on installing third-party modules, see the Talend Installation Guide.

 

Remote server

Select this check box if you use a Neo4j REST server, and specify the root URL in the Server URL field.

  • Set username: this check box is available when you have selected the Use a remote server check box and the Neo4j version you are using is earlier than 2.2. If the remote Neo4j server you want to connect to does not require user credentials, leave it clear.

  • Username and Password: enter the authentication information to connect to the remote Neo4j server to be used. Since Neo4j 2.2, user credentials are always required.

This check box appears only if you do not select the Use an existing connection check box.

 

Database path

If you use Neo4j in embedded mode, specify the directory to hold your data files. If the specified directory does not exist, it will be created.

This field appears only if you do not select the Use an existing connection check box or the Remote server check box.

 

Shutdown after job (Only embedded database)

Select this check box if you want to shutdown the Neo4j database connection at the end of the Job.

This check box is available only if the Use an existing connection check box is selected.

 

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. The schema is either Built-In or stored remotely in the Repository.

Since version 5.6, both the Built-In mode and the Repository mode are available in any of the Talend solutions.

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. Related topic: see Talend Studio User Guide.

 

 

Repository: You have already created the schema and stored it in the Repository. You can reuse it in various projects and Job designs. Related topic: see Talend Studio User Guide.

When the schema to be reused has default values that are integers or functions, ensure that these default values are not enclosed within quotation marks. If they are, you must remove the quotation marks manually.

For more details, see the article Verifying default values in a retrieved schema on Talend Help Center (https://help.talend.com).

 

Query

Enter your Cypher query in double quotes. If you have some parameters corresponding to the input schema columns, declare them with curly brackets ({}) and map them in the Parameters table.

 

Parameters

Click the [+] button to add parameters corresponding to your Cypher query and map them with the input schema columns.

  • Parameter name: Type in the name of your parameter, in double quotes.

  • Parameter value: Select the schema column you want to map your parameter with.

 

Die on error

This check box is selected by default. Clear the check box to skip the row on error and complete the process for error-free rows.

Advanced settings

tStatCatcher Statistics

Select this check box to gather the Job processing metadata at the Job level as well as at each component level.

 

Commit every

Enter the number of rows to be completed before committing batches of nodes together the database. This option ensures transaction quality (but not rollback) and, above all, better performance at execution.

Warning

This option is only supported by the embedded mode of the database. You can't make transactions in REST mode.

Global Variables

NB_NODE_INSERTED: the number of nodes inserted. This is an After variable and it returns a long.

NB_RELATIONSHIP_INSERTED: the number of relationships inserted. This is an After variable and it returns a long.

NB_PROPERTY_UPDATED: the number of properties updated. This is an After variable and it returns a long.

NB_NODE_DELETED: the number of nodes deleted. This is an After variable and it returns a long.

NB_RELATIONSHIP_DELETED: the number of relationships deleted. This is an After variable and it returns a long.

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.

UsageThis component can be used as a standalone component or as an output component in a process.
Limitationn/a

Scenario 1: Creating nodes with a label using a Cypher query

This scenario describes a Job that creates nodes with a label in an embedded Neo4j database using a Cypher query, and then displays some properties of the specified node on the console.

Adding and linking components

  1. Create a Job and add the following components to the Job by typing theirs names in the design workspace or dropping them from the Palette:

    • a tNeo4jConnection component, to open a connection to a Neo4j database,

    • a tNeo4jRow component, to create nodes in the Neo4j database with a Cypher query,

    • a tNeo4jIntput component, to read the specified properties of the created nodes,

    • a tLogRow component, to display the data on the Run console, and

    • a tNeo4jClose component, to close the Neo4j database connection established by the tNeo4jConnection component.

  2. Link the tNeo4jConnection component to the tNeo4jRow component using a Trigger > On Subjob Ok connection.

  3. Link the tNeo4jRow component to the tNeo4jIntput component using a Trigger > On Subjob Ok connection.

  4. Link the tNeo4jIntput component to the tLogRow component using a Row > Main connection.

  5. Link the tNeo4jIntput component to the tNeo4jClose component using a Trigger > On Subjob Ok connection.

Configuring the components

Configuring a Neo4j database connection and nodes creation

  1. Double-click the tNeo4jConnection component to open its Basic settings view on the Component tab.

  2. From the DB Version list, select Neo4J 2.X.X to enable node labeling support.

  3. In the Database path field, specify the directory for your data files, "E:/Talend/DB/Neo4j/data" in this example.

    In this example, you will use Neo4j in embedded mode; to connect to a remote Neo4j server via REST, click the Use a remote server check box and specify the URL of the Neo4j server.

  4. Double-click the tNeo4jRow component to open its Basic settings view on the Component tab.

  5. Select the Use an existing connection check box to reuse the Neo4j database connection opened by the tNeo4jConnection component, which is the only connection component used in this example.

  6. In the Query field, type in the Cypher query to be executed by the component.

    In this example, type in the following query to create two nodes with the label Managers and three properties - id, name, and position:

    "CREATE (a:Managers { id: 1, name: 'Gerald White', position: 'HR directory'})
    CREATE (b:Managers { id: 2, name: 'Jimmy Black', position: 'Sales manager'})"

    As this component does not have an input flow, leave the schema and the parameter settings blank.

Configuring data retrieving and display

  1. Double-click the tNeo4jInput component to open its Basic settings view.

  2. Select the Use an existing connection check box to reuse the connection opened by the tNeo4jConnection component.

  3. Click the [...] button next to Edit schema and define the schema corresponding to the node properties you want to retrieve and display. In this example, the schema is composed of two columns, name and position, both of type String.

    When done, click OK to close the [Schema] dialog box and propagate the schema to the next component.

    The defined schema columns automatically appear in the Mapping table.

  4. In the Query field, type in the Cypher query to match the data to read from the Neo4j database. In this example, use the following Cypher query to find the name and position of the manager whose ID is 2.

    "MATCH (ee:Managers{id:2}) RETURN ee.name, ee.position;"

    or

    "MATCH (ee:Managers) WHERE ee.id = 2 RETURN ee.name, ee.position;"
  5. Fill the Return parameter field for each schema column with a return parameter in double quotes to map the node properties in the Neo4j database with the schema columns.

  6. Double-click the tLogRow component to open its Basic settings view, and select the Table (print values in cells of a table) option to display the retrieved information in a table.

Executing the Job

  1. Press Ctrl+S to save the Job.

  2. Press F6 or click Run on the Run tab to run the Job.

    Two nodes are created in the Neo4j database based on the Cypher query, with the data files written in the specified directory, and the defined information is retrieved and displayed on the console.

Scenario 2: Importing data from a CSV file to Neo4j using a Cypher query

This scenario describes a Job that first imports employees data from a CSV file into a Neo4j database using a Cypher query, and then displays the information on the console.

Adding and linking components

  1. Create a Job and add the following components to the Job by typing theirs names in the design workspace or dropping them from the Palette:

    • a tNeo4jConnection component, to open a connection to a Neo4j database,

    • a tFileInputDelimited component, to read the source data from a CSV file,

    • a tNeo4jRow component, to write the employees data to the Neo4j database with a Cypher query,

    • a tNeo4jIntput component, to read the employees data from the Neo4j database,

    • a tLogRow component, to display the data on the Run console, and

    • a tNeo4jClose component, to close the Neo4j database connection opened by the tNeo4jConnection component.

  2. Link the tNeo4jConnection component to the tFileInputDelimited component using a Trigger > On Subjob Ok connection.

  3. Link the tFileInputDelimited component to the tNeo4jRow component using a Row > Main connection.

  4. Link the tFileInputDelimited component to the tNeo4jIntput component using a Trigger > On Subjob Ok connection.

  5. Link the tNeo4jIntput component to the tLogRow component using a Row > Main connection.

  6. Link the tNeo4jIntput component to the tNeo4jClose component using a Trigger > On Subjob Ok connection.

  7. Label the components to better identify their roles in the Job.

Configuring the components

Configuring a Neo4j database connection

  1. Double-click the tNeo4jConnection component to open its Basic settings view on the Component tab.

  2. From the DB Version list, select Neo4J 2.X.X.

  3. Select the Use a remote server check box and specify the URL of the Neo4j server in the Server URL field, "http://localhost:7474/db/data" in this example.

    In this example, you will use Neo4j in REST mode; to connect to a remote Neo4j server in embedded mode, clear the Use a remote server check box and specify the Neo4j data file directory in the Database path field.

Configuring data import

  1. Double-click the tFileInputDelimited component to open its Basic settings view on the Component tab.