You are viewing documentation about an older version (1.3.0). View latest version

snowflake.snowpark.DataFrame.natural_join

DataFrame.natural_join(right: DataFrame, how: str | None = None, **kwargs) DataFrame[source]

Performs a natural join of the specified type (how) with the current DataFrame and another DataFrame (right).

Parameters:
  • right – The other DataFrame to join.

  • how

    We support the following join types:

    • Inner join: “inner” (the default value)

    • Left outer join: “left”, “leftouter”

    • Right outer join: “right”, “rightouter”

    • Full outer join: “full”, “outer”, “fullouter”

    You can also use join_type keyword to specify this condition. Note that to avoid breaking changes, currently when join_type is specified, it overrides how.

Examples::
>>> df1 = session.create_dataframe([[1, 2], [3, 4], [5, 6]], schema=["a", "b"])
>>> df2 = session.create_dataframe([[1, 7], [3, 8]], schema=["a", "c"])
>>> df1.natural_join(df2).show()
-------------------
|"A"  |"B"  |"C"  |
-------------------
|1    |2    |7    |
|3    |4    |8    |
-------------------
Copy
>>> df1 = session.create_dataframe([[1, 2], [3, 4], [5, 6]], schema=["a", "b"])
>>> df2 = session.create_dataframe([[1, 7], [3, 8]], schema=["a", "c"])
>>> df1.natural_join(df2, "left").show()
--------------------
|"A"  |"B"  |"C"   |
--------------------
|1    |2    |7     |
|3    |4    |8     |
|5    |6    |NULL  |
--------------------
Copy