snowflake.snowpark.DataFrame.crossJoin¶
- DataFrame.crossJoin(right: DataFrame, *, lsuffix: str = '', rsuffix: str = '') DataFrame[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.23.0/src/snowflake/snowpark/dataframe.py#L2658-L2716)¶
- Performs a cross join, which returns the Cartesian product of the current - DataFrameand another- DataFrame(- right).- If the current and - rightDataFrames have columns with the same name, and you need to refer to one of these columns in the returned DataFrame, use the- col()function on the current or- rightDataFrame to disambiguate references to these columns.- Example: - >>> df1 = session.create_dataframe([[1, 2], [3, 4]], schema=["a", "b"]) >>> df2 = session.create_dataframe([[5, 6], [7, 8]], schema=["c", "d"]) >>> df1.cross_join(df2).sort("a", "b", "c", "d").show() ------------------------- |"A" |"B" |"C" |"D" | ------------------------- |1 |2 |5 |6 | |1 |2 |7 |8 | |3 |4 |5 |6 | |3 |4 |7 |8 | ------------------------- >>> df3 = session.create_dataframe([[1, 2], [3, 4]], schema=["a", "b"]) >>> df4 = session.create_dataframe([[5, 6], [7, 8]], schema=["a", "b"]) >>> df3.cross_join(df4, lsuffix="_l", rsuffix="_r").sort("a_l", "b_l", "a_r", "b_r").show() --------------------------------- |"A_L" |"B_L" |"A_R" |"B_R" | --------------------------------- |1 |2 |5 |6 | |1 |2 |7 |8 | |3 |4 |5 |6 | |3 |4 |7 |8 | --------------------------------- - Parameters:
- right – the right - DataFrameto join.
- lsuffix – Suffix to add to the overlapping columns of the left DataFrame. 
- rsuffix – Suffix to add to the overlapping columns of the right DataFrame. 
 
 - Note - If both - lsuffixand- rsuffixare empty, the overlapping columns will have random column names in the result DataFrame. If either one is not empty, the overlapping columns won’t have random names.