bundle_adb_360/src/c_Incremental/14_Scd2ToGold.py [204:237]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    }) \
    .whenNotMatchedInsertAll() \
    .execute()

# COMMAND ----------


# calculate watermark record
wmdf = tcdf.selectExpr(
    'max(_commit_version) as lastCommitKey',
    'max(_commit_timestamp) as lastTimeStamp',
    ).withColumn('tablename', lit(tablename))


# COMMAND ----------

# udpate watermark table 
deltaWm = DeltaTable.forName(spark, 'golddb.watermarktable')
deltaWm.alias('t') \
.merge(
    wmdf.alias('u'),
    't.tablename = u.tablename'
) \
.whenMatchedUpdate(set=
{
    'lastCommitKey' : 'u.lastCommitKey'
}
) \
.execute()


# COMMAND ----------

print ("finished")
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



