Skip to content

Conversation

@rloredo
Copy link

@rloredo rloredo commented Jan 3, 2025

Solves elementary-data/elementary#1766

Summary by CodeRabbit

  • New Features
    • Added BigQuery support for more flexible data update operations with conditional delete and insert logic for improved data management.

@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Walkthrough

A new BigQuery-specific macro has been added to construct and return delete and insert queries with conditional logic. The macro accepts parameters for the target relation, insert relation, delete relation, and delete column key, accumulating the appropriate queries based on which relations are provided.

Changes

Cohort / File(s) Summary
BigQuery delete and insert queries macro
macros/utils/table_operations/delete_and_insert.sql
Added bigquery__get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) macro that conditionally constructs delete queries when delete_relation is provided and insert queries when insert_relation is provided, returning the accumulated query list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify SQL syntax for delete and insert query construction
  • Confirm conditional logic correctly evaluates the presence of delete_relation and insert_relation
  • Check parameter usage and ensure delete_column_key is properly utilized in delete conditions

Poem

A rabbit hops through queries new, ✨
Delete then insert, tried and true,
BigQuery dances left and right,
With conditional logic shining bright! 🐰

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Remove transaction for bigquery in delete_and_insert macro' accurately describes the main change: removing transaction handling from the BigQuery delete_and_insert macro.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2c599d1 and 044d5a8.

📒 Files selected for processing (1)
  • macros/utils/table_operations/delete_and_insert.sql (1 hunks)
🔇 Additional comments (1)
macros/utils/table_operations/delete_and_insert.sql (1)

136-157: Implementation correctly removes transaction wrapper for BigQuery.

The macro properly constructs separate delete and insert queries without wrapping them in a transaction, which aligns with BigQuery's DML semantics and addresses the issue raised in #1766.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

{% do return(queries) %}
{% endmacro %}

{% macro bigquery__get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While your implementation is valid, your end goal of running 2 dbt runs in parallel won't be resolved by this.
Commented on the issue.

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