tdJoin: tdJoin

Description Usage Arguments Details Value See Also Examples

Description

Takes two (or more) Teradata EDW tables using a JDBC connection object via the RJDBC package and merges them together.

Usage

1
2
tdJoin(tdfO, tdf1, tdf2, index1, index2, col1 = NULL, col2 = NULL,
  joinType = "inner", ...)

Arguments

tdfO

Name of resulting Teradata to output.

tdf1

Name of first Teradata table to merge.

tdf2

Name of second Teradata table to merge.

index1

Name of index from first table to merge by.

index2

Name of index from second table to merge by.

col1

Name of columns from first table to merge.

col2

Name of columns from second table to merge.

joinType

Type of merge to perform. Needs to be one of following: inner, left outer, right outer, full outer.

...

Additional tdfX and indexX to merge, where X is the count. Also can take optional connection settings.

Details

By default, the code tries to do joins starting from Table 1 going up. So if, for example, three tables are provided for inner joins, then Table 1 and Table 2 will first be inner joined, and the resulting output will then be inner joined with Table 3. If a left join is desired for the three tables, then Table 2 will be left joined to Table 1 and Table 3 will then be left joined with the resulting table.

If desired, column names for each table can be provided to merge together. By default, the code will try to use all columns of the tables provided. All tables will be searched for duplicate column names. If any exists, then copies will be renamed with a suffix of _copyX where X represents the number of copies. If an index name merging by has copies across the tables, then only one index name is kept.

If a connection profile (e.g. username, password, etc.) is provided, then an attempt is made to connect to Teradata. Once the query is run, the connection is then closed. If a connection object (conn) is provided to the function (or one is found globally), then the connection remains open.

Value

The code creates the data table on the Teradata server via the JDBCConnection object. Names of each table created are returned as a string vector.

See Also

tdConn for connection, tdDisk for disk usage, tdSpool for spool usage, tdCpu for CPU usage, and td for general queries.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## NOT RUN ##
## With connection pre-established, inner join on table ##
# conn = tdConn(<username>, <password>)
# tdJoin(<outputTable>, <inputTable1>, <inputTable2>, <index1>, <index2>)

## inner join on table with select columns ##
# tdJoin(<outputTable>, <inputTable1>, <inputTable2>, <index1>, <index2>, joinType="left")

## left join on table ##
# tdJoin(<outputTable>, <inputTable1>, <inputTable2>, <index1>, <index2>, joinType="left")

tranlm/tdR documentation built on May 31, 2019, 7:45 p.m.