Fix column quoting in incremental merge strategy for SQL keywords - #308
Open
mlilius wants to merge 5 commits into
Open
Fix column quoting in incremental merge strategy for SQL keywords#308mlilius wants to merge 5 commits into
mlilius wants to merge 5 commits into
Conversation
- Quote column names in incremental merge strategy to handle SQL keywords - Add comprehensive tests for incremental materialization with keyword columns - Test validates proper handling of columns named 'language' and 'count' - Ensures incremental updates work correctly with quoted column names
mlilius
force-pushed
the
incremental-keyword-quotation
branch
from
September 3, 2025 01:22
0788e07 to
938dee2
Compare
|
@mlilius - looks like there are some conflicts ? |
Author
|
@ianils - the conflict is taken care of. |
…ategy - Updated the incremental merge strategy to quote unique keys and column names using the adapter's quote function, ensuring compatibility with SQL keywords. - Adjusted the macro signature to include an optional parameter for incremental predicates, enhancing flexibility in SQL generation.
…essary quoting for column names. This change ensures that the column names are directly referenced, improving clarity and consistency in the SQL generation process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix column quoting in incremental merge strategy for SQL keywords to prevent SQL errors when column names are SQL keywords.
Description
This PR addresses an issue where SQL keyword column names (like 'language', 'count', 'order', etc.) were not being properly quoted in incremental materialization merge strategies. When users had columns with these names, the generated SQL would fail because the column names weren't quoted.
Changes made:
adapter.quote(column_name)instead of raw column namesFiles changed:
dbt/include/dremio/macros/materializations/incremental/strategies.sql: Added proper column quotingtests/functional/adapter/materialization/test_incremental.py: AddedTestIncrementalColumnQuotingtest classCHANGELOG.md: Added entry for this fixTest Results
Added new test
TestIncrementalColumnQuoting.test_incremental_keyword_columnsthat validates:The test creates a model with columns named 'language' and 'count' (both SQL keywords) and verifies that incremental materialization works correctly with the merge strategy.
Changelog
Contributor License Agreement