MatchedClauseBuilder (Snowpark Java API Reference 1.21.0)

Package com.snowflake.snowpark_java

## Class MatchedClauseBuilder

- java.lang.Object
- - com.snowflake.snowpark_java.MatchedClauseBuilder

-     public class MatchedClauseBuilder
      extends java.lang.Object

  Builder for a matched clause. It provides APIs to build update and delete actions
  Since:
    1.1.0

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `MergeBuilder` | `delete()` | Defines a delete action for the matched clause, when a row in target is matched, delete it from target.
    `MergeBuilder` | `update​(java.util.Map<Column,​Column> assignments)` | Defines an update action for the matched clause, when a row in target is matched, update the row in target with `assignments`, where the key specifies column name and value specifies its assigned value.
    `MergeBuilder` | `updateColumn​(java.util.Map<java.lang.String,​Column> assignments)` | Defines an update action for the matched clause, when a row in target is matched, update the row in target with `assignments`, where the key specifies column name and value specifies its assigned value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### update

          public MergeBuilder update​(java.util.Map<Column,​Column> assignments)

      Defines an update action for the matched clause, when a row in target is matched, update the row in target with `assignments`, where the key specifies column name and value specifies its assigned value. Returns an updated `MergeBuilder` with the new clause added.

      For example:

           Map<Column, Column> assignments = new HashMap<>();
           assignments.put(Functions.col("col_1"), df.col("col_b"));
           session.table("table").merge(df, Functions.col("col_1").equal_to(df.col("col_a")))
             .whenMatched().update(assignments).collect();

      Parameters:
        `assignments` - A map contains the column being updated and the new value.
      Returns:
        `MergeBuilder`
      Since:
        1.1.0

    - #### updateColumn

          public MergeBuilder updateColumn​(java.util.Map<java.lang.String,​Column> assignments)

      Defines an update action for the matched clause, when a row in target is matched, update the row in target with `assignments`, where the key specifies column name and value specifies its assigned value. Returns an updated `MergeBuilder` with the new clause added.

      For example:

           Map<String, Column> assignments = new HashMap<>();
           assignments.put("col_1", df.col("col_b"));
           session.table("table").merge(df, Functions.col("col_1").equal_to(df.col("col_a")))
             .whenMatched(Functions.col("col_2").equal_to(Functions.lit(true)))
             .update(assignments).collect();

      Parameters:
        `assignments` - A map contains the column being updated and the new value.
      Returns:
        `MergeBuilder`
      Since:
        1.1.0

    - #### delete

          public MergeBuilder delete()

      Defines a delete action for the matched clause, when a row in target is matched, delete it from target. Returns an updated `MergeBuilder` with the new clause added.

      For example:

           session.table("table").merge(df, Functions.col("col_1").equal_to(df.col("col_a")))
             .whenMatched(Functions.col("col_2").equal_to(Functions.lit(true)))
             .delete().collect();

      Returns:
        `MergeBuilder`
      Since:
        1.1.0