dbt-labs / dbt-snowflake

dbt-snowflake contains all of the code enabling dbt to work with Snowflake
https://getdbt.com
Apache License 2.0
296 stars 176 forks source link

fix: [microbatch] delete redundant using clause #1214

Open ugmuka opened 1 month ago

ugmuka commented 1 month ago

resolves #1198

Problem

The microbatch feature generates a DELETE SQL statement that includes a redundant USING clause. The current SQL looks like this:

delete from <target_model_name> DBT_INTERNAL_TARGET
    using <tmp_table>
    where (
    DBT_INTERNAL_TARGET.event_date >= TIMESTAMP '2024-10-13 00:00:00+00:00'
    and DBT_INTERNAL_TARGET.event_date < TIMESTAMP '2024-10-14 00:00:00+00:00'

    );

This results in a Cartesian join, which is unnecessary. To resolve this issue, the USING clause should be removed.

Solution

Remove the USING clause from merge.sql.

Checklist

cla-bot[bot] commented 1 month ago

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @ugmuka

ugmuka commented 1 month ago

I have signed CLA.

colin-rogers-dbt commented 1 month ago

@cla-bot check

cla-bot[bot] commented 1 month ago

The cla-bot has been summoned, and re-checked this pull request!