Class NotMatchedClauseBuilder


  • public class NotMatchedClauseBuilder
    extends java.lang.Object
    Builder for a not matched clause. It provides APIs to build insert actions
    Since:
    1.1.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MergeBuilder insert​(Column[] values)
      Defines an insert action for the not matched clause, when a row in source is not matched, insert a row in target with 'values'.
      MergeBuilder insert​(java.util.Map<Column,​Column> assignments)
      Defines an insert action for the not matched clause, when a row in source is not matched, insert a row in target with 'assignments', where the key specifies column name and value specifies its assigned value.
      MergeBuilder insertRow​(java.util.Map<java.lang.String,​Column> assignments)
      Defines an insert action for the not matched clause, when a row in source is not matched, insert a 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

      • insert

        public MergeBuilder insert​(Column[] values)
        Defines an insert action for the not matched clause, when a row in source is not matched, insert a row in target with 'values'. Returns an updated MergeBuilder with the new clause added.

        For example:

        
         session.table("tableName").merge(df, Functions.col("col_1").equal_to(df.col("col_a")))
           .whenNotMatched().insert(new Column[]{df.col("col_b"), Functions.lit("c"), Functions.lit(true)})
           .collect();
         
        Note: This API inserts into all columns in target with values, so the length of 'values' must equal the number of columns in target.
        Parameters:
        values - The valued being inserted
        Returns:
        MergeBuilder
        Since:
        1.1.0
      • insert

        public MergeBuilder insert​(java.util.Map<Column,​Column> assignments)
        Defines an insert action for the not matched clause, when a row in source is not matched, insert a row in target with 'assignments', where the key specifies column name and value specifies its assigned value. All unspecified columns are set to NULL. Returns an updated MergeBuilder with the new clause added.
        
         Map<Column, Column> assignments = new HashMap<>();
         assignments.put(Functions.col("col_1"), df.col("col_b"));
         session.table("tableName").merge(df, Functions.col("col_1").equal_to(df.col("col_a")))
           .whenNotMatched(df.col("col_a").equal_to(Functions.lit(3)))
           .insert(assignments).collect();
         
        Parameters:
        assignments - A map contains row data.
        Returns:
        MergeBuilder
        Since:
        1.1.0
      • insertRow

        public MergeBuilder insertRow​(java.util.Map<java.lang.String,​Column> assignments)
        Defines an insert action for the not matched clause, when a row in source is not matched, insert a row in target with 'assignments', where the key specifies column name and value specifies its assigned value. All unspecified columns are set to NULL. 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("tableName").merge(df, Functions.col("col_1").equal_to(df.col("col_a")))
           .whenNotMatched(df.col("col_a").equal_to(Functions.lit(3)))
           .insertRow(assignments).collect();
         
        Parameters:
        assignments - A map contains row data.
        Returns:
        MergeBuilder
        Since:
        1.1.0