You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/08/14 19:47:00 UTC

[jira] [Commented] (AIRFLOW-4734) Upsert functionality for PostgresHook.insert_rows()

    [ https://issues.apache.org/jira/browse/AIRFLOW-4734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17178033#comment-17178033 ] 

ASF subversion and git services commented on AIRFLOW-4734:
----------------------------------------------------------

Commit cafeb81d60a269cc7fb48bd177bbbe46833ea79f in airflow's branch refs/heads/v1-10-test from William Tran
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=cafeb81 ]

[AIRFLOW-4734] Upsert functionality for PostgresHook.insert_rows() (#8625)

PostgresHook's parent class, DbApiHook, implements upsert in its insert_rows() method
with the replace=True flag. However, the underlying generated SQL is specific to MySQL's
"REPLACE INTO" syntax and is not applicable to PostgreSQL.

This pulls out the sql generation code for insert/upsert out in to a method that is then
overridden in the PostgreSQL subclass to generate the "INSERT ... ON CONFLICT DO
UPDATE" syntax ("new" since Postgres 9.5)

(cherry picked from commit a28c66f23d373cd0f8bfc765a515f21d4b66a0e9)


> Upsert functionality for PostgresHook.insert_rows()
> ---------------------------------------------------
>
>                 Key: AIRFLOW-4734
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4734
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: hooks
>    Affects Versions: 1.10.3
>            Reporter: William Tran
>            Assignee: William Tran
>            Priority: Minor
>              Labels: features
>             Fix For: 2.0.0
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> PostgresHook's parent class, DbApiHook, implements upsert in its insert_rows() method with the replace=True flag. However, the underlying generated SQL is specific to MySQL's "REPLACE INTO" syntax and is not applicable to Postgres.
> I'd like to override this method in PostgresHook to implement the "INSERT ... ON CONFLICT DO UPDATE" syntax (new since Postgres 9.5)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)