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

Hybrid table materialization #1296

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

Conversation

AkhilGurrapu
Copy link

Add Snowflake Hybrid Table Materialization

Description

This PR introduces a new materialization for Snowflake Hybrid Tables, enabling dbt users to leverage the benefits of both regular and dynamic tables in their data models. The implementation provides support for incremental processing, primary keys, and secondary indexes while maintaining dbt's idiomatic approach to data transformations.

Features

  • Custom hybrid_table materialization for Snowflake
  • Support for column-level definitions and constraints
  • Primary key enforcement
  • Secondary index management
  • Incremental processing using MERGE operations
  • Full refresh capabilities

Example Usage

{{config(
    materialized='hybrid_table',
    column_definitions={
        'customer_id': 'VARCHAR NOT NULL',
        'order_id': 'VARCHAR NOT NULL',
        'amount': 'NUMBER',
        'created_at': 'TIMESTAMP'
    },
    primary_key=['customer_id', 'order_id'],
    indexes=[
        {'name': 'idx_customer', 'columns': ['customer_id']},
        {'name': 'idx_created', 'columns': ['created_at']}
    ]
)}}

SELECT
    customer_id,
    order_id,
    amount,
    created_at
FROM source_table

Implementation Details

  • Added hybrid_table.sql materialization
  • Implemented configuration validation
  • Added support for incremental processing
  • Included comprehensive error handling
  • Added documentation and examples

Requirements

  • dbt-core >= 1.5.0
  • dbt-snowflake >= 1.5.0
  • Snowflake Enterprise Edition or higher

Testing

  • Added unit tests for materialization logic
  • Included integration tests with Snowflake
  • Tested incremental scenarios
  • Verified error handling
  • Tested performance with large datasets

Documentation

  • Added materialization reference docs
  • Included configuration examples
  • Added best practices guide
  • Documented limitations and requirements

Breaking Changes

None. This is an additive feature that doesn't affect existing materializations.

Checklist

  • Added new materialization file
  • Implemented configuration validation
  • Added comprehensive tests
  • Updated documentation
  • Tested with various scenarios
  • Followed dbt coding standards
  • Added error handling
  • Verified Snowflake compatibility

@AkhilGurrapu AkhilGurrapu requested a review from a team as a code owner January 27, 2025 04:08
Copy link

cla-bot bot commented Jan 27, 2025

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: @AkhilGurrapu

@sfc-gh-jdemlow
Copy link

Did you want help with this?

@sfc-gh-jdemlow
Copy link

considering this is code I wrote I am sure I can help here

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