79525128

Date: 2025-03-21 10:09:20
Score: 0.5
Natty:
Report link

For anyone who can help, we were able to find the solution.

The problem occurred because we have a field called 0PRICE.CURRENCY and the command was misinterpreting it.

We added a ` before and after the field name and it solved it.

# Carregar a tabela Delta
delta_table = DeltaTable.forPath(spark, abfss_path_target)

# Construir a condição de correspondência
condicao_correspondencia = " AND ".join([f"t.{chave} = s.{chave}" for chave in chave_unica])

# Usar o comando MERGE para atualizar ou inserir dados
delta_table.alias("t").merge(
    novos_registros.alias("s"),
    condicao_correspondencia  # Usar a condição de correspondência construída
).whenMatchedUpdate(set={f"`{col}`": f"s.`{col}`" for col in lista_campos}
).whenNotMatchedInsert(values={f"`{col}`": f"s.`{col}`" for col in lista_campos}
).execute()
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Marcelo Herdy