MergeBuilder (Snowpark Java API Reference 1.20.0)

Package com.snowflake.snowpark_java

## Class MergeBuilder

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

-     public class MergeBuilder
      extends java.lang.Object

  Builder for a merge action. It provides APIs to build matched and not matched clauses.
  Since:
    1.1.0

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `MergeBuilderAsyncActor` | `async()` | Returns a `MergeBuilderAsyncActor` object that can be used to execute MergeBuilder actions asynchronously.
    `MergeResult` | `collect()` | Executes the merge action and returns a `MergeResult`, representing number of rows inserted, updated and deleted by this merge action.
    `MatchedClauseBuilder` | `whenMatched()` | Adds a matched clause into the merge action.
    `MatchedClauseBuilder` | `whenMatched​(Column condition)` | Adds a matched clause into the merge action.
    `NotMatchedClauseBuilder` | `whenNotMatched()` | Adds a not matched clause into the merge action.
    `NotMatchedClauseBuilder` | `whenNotMatched​(Column condition)` | Adds a matched clause into the merge action.

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

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

- - ### Method Detail

    - #### whenMatched

          public MatchedClauseBuilder whenMatched()

      Adds a matched clause into the merge action. It matches all remaining rows in target that satisfy 'joinExpr'. Returns a `MatchedClauseBuilder` which provides APIs to define actions to take when a row is matched.

      Caution: Since it matches all remaining rows, no more whenMatched calls will be accepted beyond this call.

      Returns:
        `MatchedClauseBuilder`
      Since:
        1.1.0

    - #### whenMatched

          public MatchedClauseBuilder whenMatched​(Column condition)

      Adds a matched clause into the merge action. It matches all rows in target that satisfy 'joinExpr' while also satisfying 'condition'. Returns a `MatchedClauseBuilder` which provides APIs to define actions to take when a row is matched.
      Parameters:
        `condition` - The condition expression
      Returns:
        `MatchedClauseBuilder`
      Since:
        1.1.0

    - #### whenNotMatched

          public NotMatchedClauseBuilder whenNotMatched()

      Adds a not matched clause into the merge action. It matches all remaining rows in source that do not satisfy 'joinExpr'. Returns a `MatchedClauseBuilder` which provides APIs to define actions to take when a row is not matched.

      Caution: Since it matches all remaining rows, no more whenNotMatched calls will be accepted beyond this call.

      Returns:
        `NotMatchedClauseBuilder`
      Since:
        1.1.0

    - #### whenNotMatched

          public NotMatchedClauseBuilder whenNotMatched​(Column condition)

      Adds a matched clause into the merge action. It matches all rows in target that satisfy 'joinExpr' while also satisfying 'condition'. Returns a `MatchedClauseBuilder` which provides APIs to define actions to take when a row is matched.
      Parameters:
        `condition` - The condition expression
      Returns:
        `MatchedClauseBuilder`
      Since:
        1.1.0

    - #### collect

          public MergeResult collect()

      Executes the merge action and returns a `MergeResult`, representing number of rows inserted, updated and deleted by this merge action.
      Returns:
        `MergeResult`
      Since:
        1.1.0

    - #### async

          public MergeBuilderAsyncActor async()

      Returns a `MergeBuilderAsyncActor` object that can be used to execute MergeBuilder actions asynchronously.
      Returns:
        A `MergeBuilderAsyncActor` object
      Since:
        1.3.0