crossjoin | teradatamlspk | pyspark2teradataml - crossjoin - Teradata Package for Python

Teradata® pyspark2teradataml User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-11
dita:mapPath
oeg1710443196055.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
oeg1710443196055
Product Category
Teradata Vantage

When using crossjoin in teradatamlspk, if both input DataFrames share common column names, then column names for those columns are prefixed with 'l' and 'r' in the output DataFrame.

Also the order of the columns varies.

PySpark

>>> df1.crossJoin(df).show()
|dept_name|dept_id|dept_name|dept_id|
+---------+-------+---------+-------+
|  Finance|     10|  Finance|     10|
|  Finance|     10|Marketing|     20|
|  Finance|     10|    Sales|     30|
|  Finance|     10|       IT|     40|
|Marketing|     20|  Finance|     10|
|Marketing|     20|Marketing|     20|
|Marketing|     20|    Sales|     30|
|Marketing|     20|       IT|     40|
|    Sales|     30|  Finance|     10|
|    Sales|     30|Marketing|     20|
|    Sales|     30|    Sales|     30|
|    Sales|     30|       IT|     40|
|       IT|     40|  Finance|     10|
|       IT|     40|Marketing|     20|
|       IT|     40|    Sales|     30|
|       IT|     40|       IT|     40|
+---------+-------+---------+-------+

teradatamlspk

>>> df1.crossJoin(df).show()
+-----------+-----------+---------+---------+
|l_dept_name|r_dept_name|l_dept_id|r_dept_id|
+-----------+-----------+---------+---------+
|      Sales|    Finance|       30|       10|
|    Finance|  Marketing|       10|       20|
|  Marketing|  Marketing|       20|       20|
|      Sales|  Marketing|       30|       20|
|    Finance|      Sales|       10|       30|
|  Marketing|      Sales|       20|       30|
|      Sales|      Sales|       30|       30|
|         IT|      Sales|       40|       30|
|    Finance|         IT|       10|       40|
|  Marketing|         IT|       20|       40|
|      Sales|         IT|       30|       40|
|         IT|         IT|       40|       40|
|         IT|  Marketing|       40|       20|
|         IT|    Finance|       40|       10|
|  Marketing|    Finance|       20|       10|
|    Finance|    Finance|       10|       10|
+-----------+-----------+---------+---------+