Updatable (Snowpark Java API Reference 1.19.0)

Package com.snowflake.snowpark_java

## Class Updatable

- java.lang.Object
- - com.snowflake.snowpark.internal.Logging
  - - com.snowflake.snowpark_java.DataFrame
    - - com.snowflake.snowpark_java.Updatable

- All Implemented Interfaces:
    `java.lang.Cloneable`

      public class Updatable
      extends DataFrame

  Represents a lazily-evaluated Updatable. It extends `DataFrame` so all `DataFrame` operations can be applied on it.

  '''Creating an Updatable'''

  You can create an Updatable by calling `Session.table` with the name of the Updatable.

  Since:
    1.1.0

- - ### Field Summary

    - ### Fields inherited from class com.snowflake.snowpark.internal.Logging

      `logName`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `UpdatableAsyncActor` | `async()` | Returns an UpdatableAsyncActor object that can be used to execute Updatable actions asynchronously.
    `Updatable` | `clone()` | Returns a clone of this Updatable.
    `DeleteResult` | `delete()` | Deletes all rows in the updatable and returns a `DeleteResult`, representing number of rows deleted.
    `DeleteResult` | `delete​(Column condition)` | Deletes all rows in the updatable that satisfy specified condition and returns a `DeleteResult`, representing number of rows deleted.
    `DeleteResult` | `delete​(Column condition, DataFrame sourceData)` | Deletes all rows in the updatable that satisfy specified condition where condition includes columns in other `DataFrame`, and returns a `DeleteResult`, representing number of rows deleted.
    `MergeBuilder` | `merge​(DataFrame source, Column joinExpr)` | Initiates a merge action for this updatable with `DataFrame` source on specified join expression.
    `UpdateResult` | `update​(java.util.Map<Column,​Column> assignments)` | Updates all rows in the Updatable with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.
    `UpdateResult` | `update​(java.util.Map<Column,​Column> assignments, Column condition)` | Updates all rows in the updatable that satisfy specified condition with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.
    `UpdateResult` | `update​(java.util.Map<Column,​Column> assignments, Column condition, DataFrame sourceData)` | Updates all rows in the updatable that satisfy specified condition where condition includes columns in other `DataFrame`, and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.
    `UpdateResult` | `updateColumn​(java.util.Map<java.lang.String,​Column> assignments)` | Updates all rows in the updatable with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.
    `UpdateResult` | `updateColumn​(java.util.Map<java.lang.String,​Column> assignments, Column condition)` | Updates all rows in the updatable that satisfy specified condition with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.
    `UpdateResult` | `updateColumn​(java.util.Map<java.lang.String,​Column> assignments, Column condition, DataFrame sourceData)` | Updates all rows in the updatable that satisfy specified condition where condition includes columns in other `DataFrame`, and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

    - ### Methods inherited from class com.snowflake.snowpark_java.DataFrame

      `agg, alias, cacheResult, col, collect, count, createOrReplaceTempView, createOrReplaceTempView, createOrReplaceView, createOrReplaceView, crossJoin, cube, cube, distinct, drop, drop, dropDuplicates, except, explain, filter, first, first, flatten, flatten, groupBy, groupBy, groupByGroupingSets, intersect, isEmpty, join, join, join, join, join, join, join, join, join, join, join, join, limit, na, naturalJoin, naturalJoin, pivot, pivot, randomSplit, rename, rollup, rollup, sample, sample, schema, select, select, show, show, show, show, show, sort, sort, stat, toDF, toLocalIterator, union, unionAll, unionAllByName, unionByName, where, withColumn, withColumns, write`

    - ### Methods inherited from class com.snowflake.snowpark.internal.Logging

      `log, logDebug, logDebug, logError, logError, logInfo, logInfo, logTrace, logTrace, logWarning, logWarning, maskSecrets, maskSecrets`

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

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

- - ### Method Detail

    - #### update

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

      Updates all rows in the Updatable with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

      For example:

           Map<Column, Column> assignments = new HashMap<>;
           assignments.put(Functions.col("col1"), Functions.lit(1);
           // Assign value 1 to column col1 in all rows in updatable.
           session.table("tableName").update(assignment);

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

    - #### updateColumn

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

      Updates all rows in the updatable with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

      For example:

           Map<String, Column> assignments = new HashMap<>;
           assignments.put("col1", Functions.lit(1);
           // Assign value 1 to column col1 in all rows in updatable.
           session.table("tableName").updateColumn(assignment);

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

    - #### update

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

      Updates all rows in the updatable that satisfy specified condition with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

      For example:

           Map<Column, Column> assignments = new HashMap<>;
           assignments.put(Functions.col("col1"), Functions.lit(1);
           // Assign value 1 to column col1 in the rows if col2 is true in updatable.
           session.table("tableName").updateColumn(assignment,
             Functions.col("col2").equal_to(Functions.lit(true)));

      Parameters:
        `assignments` - A map contains the column being updated and the new value.
        `condition` - The condition of the Column being updated.
      Returns:
        `UpdateResult`
      Since:
        1.1.0

    - #### updateColumn

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

      Updates all rows in the updatable that satisfy specified condition with specified assignments and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

      For example:

           Map<String, Column> assignments = new HashMap<>;
           assignments.put("col1", Functions.lit(1);
           // Assign value 1 to column col1 in the rows if col3 is true in updatable.
           session.table("tableName").updateColumn(assignment,
             Functions.col("col2").equal_to(Functions.lit(true)));

      Parameters:
        `assignments` - A map contains the column being updated and the new value.
        `condition` - The condition of the Column being updated.
      Returns:
        `UpdateResult`
      Since:
        1.1.0

    - #### update

          public UpdateResult update​(java.util.Map<Column,​Column> assignments,
                                     Column condition,
                                     DataFrame sourceData)

      Updates all rows in the updatable that satisfy specified condition where condition includes columns in other `DataFrame`, and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

      For example:

           Map<Column, Column> assignments = new HashMap<>;
           assignments.put(Functions.col("col1"), Functions.lit(1);
           session.table("tableName").update(assignment,
             Functions.col("col2").equal_to(df.col("col_a")), df);

      Parameters:
        `assignments` - A map contains the column being updated and the new value.
        `condition` - The condition of the Column being updated.
        `sourceData` - Another DataFrame being joined.
      Returns:
        `UpdateResult`
      Since:
        1.1.0

    - #### updateColumn

          public UpdateResult updateColumn​(java.util.Map<java.lang.String,​Column> assignments,
                                           Column condition,
                                           DataFrame sourceData)

      Updates all rows in the updatable that satisfy specified condition where condition includes columns in other `DataFrame`, and returns a `UpdateResult`, representing number of rows modified and number of multi-joined rows modified.

      For example:

           Map<String, Column> assignments = new HashMap<>;
           assignments.put("col1", Functions.lit(1);
           session.table("tableName").updateColumn(assignment,
             Functions.col("col2").equal_to(df.col("col_a")), df);

      Parameters:
        `assignments` - A map contains the column being updated and the new value.
        `condition` - The condition of the Column being updated.
        `sourceData` - Another DataFrame being joined.
      Returns:
        `UpdateResult`
      Since:
        1.1.0

    - #### delete

          public DeleteResult delete()

      Deletes all rows in the updatable and returns a `DeleteResult`, representing number of rows deleted.
      Returns:
        `DeleteResult`
      Since:
        1.1.0

    - #### delete

          public DeleteResult delete​(Column condition)

      Deletes all rows in the updatable that satisfy specified condition and returns a `DeleteResult`, representing number of rows deleted.

      For example:

           session.table("tableName").delete(Functions.col("col1").equal_to(Functions.lit(1)));

      Parameters:
        `condition` - The condition expression
      Returns:
        `DeleteResult`
      Since:
        1.1.0

    - #### delete

          public DeleteResult delete​(Column condition,
                                     DataFrame sourceData)

      Deletes all rows in the updatable that satisfy specified condition where condition includes columns in other `DataFrame`, and returns a `DeleteResult`, representing number of rows deleted.

      For example:

           session.table(tableName).delete(Functions.col("col1").equal_to(df.col("col2")), df);

      Parameters:
        `condition` - The condition expression
        `sourceData` - The source DataFrame
      Returns:
        `DeleteResult`
      Since:
        1.1.0

    - #### merge

          public MergeBuilder merge​(DataFrame source,
                                    Column joinExpr)

      Initiates a merge action for this updatable with `DataFrame` source on specified join expression. Returns a `MergeBuilder` which provides APIs to define merge clauses.
      Parameters:
        `source` - The source DataFrame
        `joinExpr` - The join expression
      Returns:
        `MergeBuilder`
      Since:
        1.1.0

    - #### clone

          public Updatable clone()

      Returns a clone of this Updatable.
      Overrides:
        `clone` in class `DataFrame`
      Returns:
        `Updatable`
      Since:
        1.1.0

    - #### async

          public UpdatableAsyncActor async()

      Returns an UpdatableAsyncActor object that can be used to execute Updatable actions asynchronously.
      Overrides:
        `async` in class `DataFrame`
      Returns:
        A UpdatableAsyncActor object
      Since:
        1.2.0