1 year ago

#387465

test-img

Dineshvarma Guduru

How to merge table in snowflake using snowpark scala

I have a table named SOME_SNOWFLAKE_TABLE in snowflake

I want to Merge SOME_SNOWFLAKE_TABLE with another table SOME_TARGET_TABLE in snowflake.

Below is the approach provided in snowflake documentation. But this is not working for me.

target.merge(source, target("id") === source("id"))
  .whenMatched.update(Map("description" -> source("description")))
  .collect()

My approach is below, but it failed.

val source = session.table("SOME_SNOWFLAKE_TABLE")
val target_table = "SOME_TARGET_TABLE"

target_table.merge(source, target_table("id") === source("id"))
  .whenMatched.update(Map("description" -> source("description")))
  .collect()

I tried another approach as shown below, it also failed.

val source = session.table("SOME_SNOWFLAKE_TABLE")
val target_table = session.table("SOME_TARGET_TABLE")

target_table.merge(source, target_table("id") === source("id"))
  .whenMatched.update(Map("description" -> source("description")))
  .collect()

Could someone help me here?

scala

snowflake-cloud-data-platform

0 Answers

Your Answer

Accepted video resources