Skip to content

Conversation

Joongho
Copy link

@Joongho Joongho commented Jun 6, 2017

This is useful when merge operation.

  1. create temp table A (like schema.A) -> run by preactions
  2. load into table A ( dbtable = A )
  3. update/insert -> run by postactions

Above scenario, table A(=dbtable) should not be created

@kyrozetera
Copy link

How is this different than setting a SaveMode?

@Joongho
Copy link
Author

Joongho commented Aug 11, 2017

It's upsert(=merge) operation.

schema.A is final target table, A is temp table.

  1. update schema.A set ... where schema.A.pk1 = A.pk1 and schema.A.pk2 = A.pk2 ...
  2. insert int schema.A
    select * from A s
    left join schema.A t
    on t.pk1=s.pk1 and t.pk2=s.pk2
    where t.pk1 is null and t.pk2 is null ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants