Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [microbatch] delete redundant using clause #1214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ugmuka
Copy link

@ugmuka ugmuka commented Oct 18, 2024

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 <tmp_table> clause should be removed.

Solution

Remove the USING <tmp_table> clause from merge.sql.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@ugmuka ugmuka requested a review from a team as a code owner October 18, 2024 05:45
Copy link

cla-bot bot commented Oct 18, 2024

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
Copy link
Author

ugmuka commented Oct 18, 2024

I have signed CLA.

@ugmuka ugmuka changed the title fix: delete redundant using clause fix: [microbatch] delete redundant using clause Oct 18, 2024
@colin-rogers-dbt
Copy link
Contributor

@cla-bot check

@cla-bot cla-bot bot added the cla:yes label Oct 18, 2024
Copy link

cla-bot bot commented Oct 18, 2024

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

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

Successfully merging this pull request may close these issues.

[Feature] Incremental strategies for delete+insert and microbatch cause unnecessary cross joins
2 participants