Primeur Online Docs
Data Shaper
Data Shaper
  • 🚀GETTING STARTED
    • What is Primeur Data Shaper
      • What is the Data Shaper Designer
      • What is the Data Shaper Server
      • What is the Data Shaper Cluster
    • How does the Data Shaper Designer work
      • Designer Views and Graphs
      • Data Shaper Graphs
      • Designer Projects and Sandboxes
      • Data Shaper Designer Reference
    • How do the Data Shaper Server and Cluster work
      • Data Shaper Server and Cluster
      • Data Shaper Server Reference
    • VFS Graph Components
      • DataOneFileDescriptor (DOFD) metadata
      • Passing parameters from Data One Contract to Data Shaper graph
      • Inheriting Data One context attributes in Data Shaper graph
  • DATA SHAPER DESIGNER
    • Configuration
      • Runtime configuration
        • Logging
        • Master Password
        • User Classpath
      • Data Shaper Server Integration
      • Execution monitoring
      • Java configuration
      • Engine configuration
      • Refresh Operation
    • Designer User Interface
      • Graph Editor with Palette of Components
      • Project Explorer Pane
      • Outline Pane
      • Tabs Pane
      • Execution Tab
      • Keyboard Shortcuts
    • Projects
      • Creating Data Shaper projects
      • Converting Data Shaper projects
      • Structure of Data Shaper projects
      • Versioning of server project content
      • Working with Data Shaper Server Projects
      • Project configuration
    • Graphs
      • Creating an empty graph
      • Creating a simple graph
        • Placing Components
        • Placing Components from Palette
        • Connecting Components with Edges
    • Execution
      • Successful Graph Execution
      • Run configuration
      • Connecting to a running job
      • Graph states
    • Common dialogs
      • URL file dialog
      • Edit Value dialog
      • Open Type dialog
    • Import
      • Import Data Shaper projects
      • Import from Data Shaper server sandbox
      • Import graphs
      • Import metadata
    • Export
      • Export graphs to HTML
      • Export to Data Shaper Server sandbox
      • Export image
      • Export Project as Library
    • Graph tracking
      • Changing record count font size
    • Search functionality
    • Working with Data Shaper server
      • Data Shaper server project basic principles
      • Connecting via HTTP
      • Connecting via HTTPS
      • Connecting via Proxy Server
    • Graph components
      • Adding components
      • Finding components
      • Edit component dialog box
      • Enable/disable component
      • Passing data through disabled component
      • Common properties of components
      • Specific attribute types
      • Metadata templates
    • Edges
      • Connecting Components with Edges
      • Types of Edges
      • Assigning Metadata to Edges
      • Colors of Edges
      • Debugging Edges
      • Edge Memory Allocation
    • Metadata
      • Records and Fields
        • Record Types
        • Data Types in Metadata
        • Data Formats
        • Locale and Locale Sensitivity
        • Time Zone
        • Autofilling Functions
      • Metadata Types
        • Internal Metadata
        • External (Shared) Metadata
        • SQL Query Metadata
        • Reading Metadata from Special Sources
      • Auto-propagated Metadata
        • Sources of Auto-Propagated Metadata
        • Explicitly Propagated Metadata
        • Priorities of Metadata
        • Propagation of SQL Query Metadata
      • Creating Metadata
        • Extracting Metadata from a Flat File
        • Extracting Metadata from an XLS(X) File
        • Extracting Metadata from a Database
        • Extracting Metadata from a DBase File
        • Extracting Metadata from Salesforce
        • SQL Query Metadata
        • User Defined Metadata
      • Merging Existing Metadata
      • Creating Database Table from Metadata and Database Connection
      • Metadata Editor
        • Opening Metadata Editor
        • Basics of Metadata Editor
        • Record Pane
        • Field Name vs. Label vs. Description
        • Details Pane
      • Changing and Defining Delimiters
      • Editing Metadata in the Source Code
      • Multi-value Fields
        • Lists and Maps Support in Components
        • Joining on multivalue fields (Comparison Rules)
    • Connections
      • Database Connections
        • Internal Database Connections
        • External (Shared) Database Connections
        • Database Connections Properties
        • Encryption of Access Password
        • Browsing Database and Extracting Metadata from Database Tables
        • Windows Authentication on Microsoft SQL Server
        • Snowflake Connection
        • Hive Connection
        • Troubleshooting
      • JMS Connections
      • QuickBase Connections
      • Hadoop Connections
      • Kafka Connections
      • OAuth2 Connections
      • MongoDB Connections
      • Salesforce Connections
    • Lookup Tables
      • Lookup Tables in Cluster Environment
      • Internal Lookup Tables
      • External (Shared) Lookup Tables
      • Types of Lookup Tables
    • Sequences
      • Persistent Sequences
      • Non Persistent Sequences
      • Internal Sequences
      • External (Shared) Sequences
      • Editing a Sequence
      • Sequences in Cluster Environment
    • Parameters
      • Internal Parameters
      • External (Shared) Parameters
      • Secure Graph Parameters
      • Graph Parameter Editor
      • Secure Graph Parameters
      • Parameters with CTL2 Expressions (Dynamic Parameters)
      • Environment Variables
      • Canonicalizing File Paths
      • Using Parameters
    • Internal/External Graph Elements
    • Dictionary
      • Creating a Dictionary
      • Using a Dictionary in Graphs
    • Execution Properties
    • Notes in Graphs
      • Placing Notes into Graph
      • Resizing Notes
      • Editing Notes
      • Formatted Text
      • Links from Notes
      • Folding Notes
      • Notes Properties
    • Transformations
      • Defining Transformations
      • Transform Editor
      • Common Java Interfaces
    • Data Partitioning (Parallel Running)
    • Data Partitioning in Cluster
      • High Availability
      • Scalability
      • Graph Allocation Examples
      • Example of Distributed Execution
      • Remote Edges
    • Readers
      • Common Properties of Readers
      • ComplexDataReader
      • DatabaseReader
      • DataGenerator
      • DataOneVFSReader
      • EDIFACTReader
      • FlatFileReader
      • JSONExtract
      • JSONReader
      • LDAPReader
      • MultiLevelReader
      • SpreadsheetDataReader
      • UniversalDataReader
      • X12Reader
      • XMLExtract
      • XMLReader
      • XMLXPathReader
    • Writers
      • Common Properties of Writers
      • DatabaseWriter
      • DataOneVFSWriter
      • EDIFACTWriter
      • FlatFileWriter
      • JSONWriter
      • LDAPWriter
      • SpreadsheetDataWriter
      • HIDDEN StructuredDataWriter
      • HIDDEN TableauWriter
      • Trash
      • UniversalDataWriter
      • X12Writer
      • XMLWriter
    • Transformers
      • Common Properties of Transformers
      • Aggregate
      • Concatenate
      • DataIntersection
      • DataSampler
      • Dedup
      • Denormalizer
      • ExtSort
      • FastSort
      • Filter
      • Map
      • Merge
      • MetaPivot
      • Normalizer
      • Partition
      • Pivot
      • Rollup
      • SimpleCopy
      • SimpleGather
      • SortWithinGroups
      • XSLTransformer
    • Joiners
      • Common Properties of Joiners
      • Combine
      • CrossJoin
      • DBJoin
      • ExtHashJoin
      • ExtMergeJoin
      • LookupJoin
      • RelationalJoin
    • Others
      • Common Properties of Others
      • CheckForeignKey
      • DBExecute
      • HTTPConnector
      • LookupTableReaderWriter
      • WebServiceClient
    • CTL2 - Data Shaper Transformation Language
    • Language Reference
      • Program Structure
      • Comments
      • Import
      • Data Types in CTL2
      • Literals
      • Variables
      • Dictionary in CTL2
      • Operators
      • Simple Statement and Block of Statements
      • Control Statements
      • Error Handling
      • Functions
      • Conditional Fail Expression
      • Accessing Data Records and Fields
      • Mapping
      • Parameters
      • Regular Expressions
    • CTL Debugging
      • Debug Perspective
      • Importing and Exporting Breakpoints
      • Inspecting Variables and Expressions
      • Examples
    • Functions Reference
      • Conversion Functions
      • Date Functions
      • Mathematical Functions
      • String Functions
      • Mapping Functions
      • Container Functions
      • Record Functions (Dynamic Field Access)
      • Miscellaneous Functions
      • Lookup Table Functions
      • Sequence Functions
      • Data Service HTTP Library Functions
      • Custom CTL Functions
      • CTL2 Appendix - List of National-specific Characters
      • HIDDEN Subgraph Functions
    • Tutorial
      • Creating a Transformation Graph
      • Filtering the records
      • Sorting the Records
      • Processing Speed-up with Parallelization
      • Debugging the Java Transformation
  • DATA SHAPER SERVER
    • Introduction
    • Administration
      • Monitoring
    • Using Graphs
      • Job Queue
      • Execution History
      • Job Inspector
    • Cluster
      • Sandboxes in Cluster
      • Troubleshooting
  • Install Data Shaper
    • Install Data Shaper
      • Introduction to Data Shaper installation process
      • Planning Data Shaper installation
      • Data Shaper System Requirements
      • Data Shaper Domain Master Configuration reference
      • Performing Data Shaper initial installation and master configuration
        • Creating database objects for PostgreSQL
        • Creating database objects for Oracle
        • Executing Data Shaper installer
        • Configuring additional firewall rules for Data Shaper
Powered by GitBook
On this page
  • Short Description
  • Ports
  • Metadata
  • DBJoin Attributes
  • Details
  • CTL Scripting Specifics
  • Java Interfaces
  • Examples
  • Best Practices
  • See also
  1. DATA SHAPER DESIGNER
  2. Joiners

DBJoin

Short Description

DBJoin receives data through a single input port and joins it with data from a database table. These two data sources can potentially have different metadata structures.

COMPONENT
SAME INPUT METADATA
SORTED INPUTS
SLAVE INPUTS
OUTPUTS
OUTPUT FOR DRIVER WITHOUT SLAVE
OUTPUT FOR SLAVES WITHOUT DRIVER
JOINING BASED ON EQUALITY
AUTO-PROPAGATED METADATA

DBJoin

x

x

1 (virtual)

1-2

✓

x

✓

✓

Ports

After the data from an input port and database table are joined, they are sent to the first output port. The second output port can optionally be used to capture unmatched master records.

PORT TYPE
NUMBER
REQUIRED
DESCRIPTION
METADATA

Input

0

✓

Master input port

Any

1 (virtual)

✓

Slave input port

Any

Output

0

✓

Output port for the joined data

Any

1

x

The optional output port for master data records without slave matches. (Only if the Join type attribute is set to Inner join.) This applies only to LookupJoin and DBJoin.

Input 0

Metadata

DBJoin propagates metadata from the first input port to the second output port and vice versa. DBJoin has no metadata template. If mapping is not defined, DBJoin requires output metadata to match metadata of a query result. If mapping is defined, metadata of a query result must match metadata defined in the DBJoin attribute.

DBJoin Attributes

ATTRIBUTE
REQ
DESCRIPTION
POSSIBLE VALUES

BASIC

Join key

yes

Key according to which the incoming data flows are joined. See Join Key below.

Left outer join

If set to true, driver records without corresponding slave are parsed, as well. Otherwise, inner join is performed.

false (default) | true

DB connection

yes

The ID of DB metadata to be used. If not set, metadata is extracted from a database using an SQL query.

Query URL

[1]

The name of an external file, including the path, defining an SQL query.

SQL query

[1]

The SQL query defined in a graph.

Transform

[2] [3]

Transformation in CTL or Java defined in the graph.

Transform URL

[2] [3]

An external file defining the transformation in CTL or Java.

Transform class

[2] [3]

An external transformation class.

Cache size

The maximum number of records with different key values that can be stored in memory.

100 (default)

ADVANCED

Transform source charset

Encoding of an external file defining the transformation. The default encoding depends on DEFAULT_SOURCE_CODE_CHARSET in defaultProperties.

E.g. UTF-8

DEPRECATED

Error actions

The definition of an action that should be performed when the specified transformation returns an Error code. See Return Values of Transformations.

Error log

A URL of the file to which error messages for specified Error actions should be written. If not set, they are written to Console.

Details

DBJoin receives data through a single input port and joins it with data from a database table. These two data sources can potentially have different metadata structure. It is a general purpose joiner usable in most common situations. It does not require the input to be sorted and is very fast as data is processed in memory.

The data attached to the first input port is called master, the second data source is called slave. Its data is considered as if it were incoming through the second (virtual) input port. Each master record is matched to the slave record on one or more fields known as a join key. The output is produced by applying a transformation that maps joined inputs to the output.

Join Key Join key is a sequence of field names from a master data source separated from each other by a semicolon, colon, or pipe. You can define the key in the Edit key wizard.

The order of these field names must correspond to the order of the key fields from the database table (and their data types). The slave part of Join key must be defined in the SQL query attribute.

One of the query attributes must contain the expression of the following form: ... where field_K=? and field_L=?.

Example 41. Join Key for DBJoin

$first_name;$last_name

This is the master part of fields that should serve to join master records with slave records. The SQL query must contain an expression that can look like this:

... where fname=? and lname=?

Corresponding fields will be compared and matching values will serve to join master and slave records.

Transformation The transform in DBJoin lets you define a transformation that sends records to the first output port. The unjoined master records sent to the second output port cannot be modified within the DBJoin transformation.

CTL Scripting Specifics

Java Interfaces

Examples

Joining on Exact Key Input records contain one field customerId with values:

1
35535
255

The customers database table has the following structure and data:

customer_id | customer_name | customer_surname
 1          | John          | Doe
 3          | Anna          | Smith
10          | Jane          | Brown

Join incoming records with data from the database on customerId.

Solution Create input metadata with one field customerId (integer) and output metadata with the customerId (integer), customerName (string), customerSurname (string) fields.

Set the Join key and **SQL query **attributes of DBJoin.

ATTRIBUTE
VALUE

Join key

customerId

DBConnection

Your DBConnection

SQL query

select * from "customers" where customer_id=?

Only records with customerId (integer) found in the database are sent to output.

Matching Range Input records contain a product code and date of order.

productCode | orderDate
1           | 2015-10-20
2           | 2015-10-30
1           | 2015-11-06

Price of a particular product on particular date can be found in the database.

productCode | dateFrom   | dateTo     | price
1           | 2014-01-01 | 2015-10-31 |  10.99
1           | 2015-11-01 | 2099-12-31 |  14.99
2           | 2015-07-01 | 2099-12-31 | 109.99

Match the price to particular product orders.

Solution Create input metadata (productCode, orderDate), output metadata (productCode, orderDate, price) and metadata for DBJoin ( productCode, price).

Set attributes:

ATTRIBUTE
VALUE

Join key

product;orderDate;orderDate

Metadata

DBJoinMetadata

DBConnection

Your DBConnection

SQL query

select product_id,price_per_unit from "dbjoin_example_02" where product_id=? and valid_from<=? and ?<=valid_to

Transform

See the code below.

//#CTL2

function integer transform() {
    $out.0.* = $in.0.*;
    $out.0.* = $in.1.*;

    return ALL;
}

Best Practices

If the transformation is specified in an external file (with Transform URL), we recommend users to explicitly specify Transform source charset.

See also

PreviousCrossJoinNextExtHashJoin

[1] One of these attributes must be specified. If both are defined, Query URL has the highest priority. [2] One of these transformation attributes should be set. Any of them must use a common CTL template for Joiners or implement a RecordTransform interface. For more information, see CTL Scripting Specifics or Java Interfaces below. For detailed information about transformations, see also . [3] A unique exception is the case when none of these three attributes are specified, but the SQL query attribute defines what records will be read from the DB table. Values of Join key contained in the input records serve to select the records from db table. These are unloaded and sent unchanged to the output port without any transformation.

All Joiners share the same transformation template which can be found in .

For detailed information about Data Shaper Transformation Language, see .

If you define your transformation in Java, it must implement the following interface that is common for all Joiners: .

Defining Transformations
CTL2 - Data Shaper Transformation Language
Common Properties of Components
Specific Attribute Types
Common Properties of Joiners
DBExecute
CTL Templates for Joiners
Java Interfaces for Joiners