Class Updatable

  • All Implemented Interfaces:
    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
    • Method Detail

      • update

        public UpdateResult update​(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​(Map<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​(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​(Map<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​(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​(Map<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