Skip to content

Conversation

@mikhail-zhadanov
Copy link
Contributor

@mikhail-zhadanov mikhail-zhadanov commented Dec 2, 2025

Hi @tglunde,

Please review my changes.
I came across across this issue in my production environment. Some source tables may have reserved keywords as column names and it's not adjustable as transferred 1-1 from upstreaming system.
So I've decided to adjust snapshot logic to be able to process such columns when they are used as identifiers.

Add proper column quoting for Exasol snapshots when unique_key or
updated_at columns use reserved SQL keywords (TIME, DATE, USER, etc).

  • Add exasol__quote_column helper macro that:
    • Passes through already-quoted columns ("time" → "time")
    • Uppercases and quotes unquoted columns (field_id → "FIELD_ID")
  • Add exasol__build_scd_args to build properly quoted scd_id arguments
  • Override snapshot_timestamp_strategy for proper quoting
  • Add exasol__snapshot_check_strategy with proper quoting for check cols
  • Add exasol__unique_key_fields macro for dbt_unique_key generation
  • Remove | upper filter from snapshot_merge.sql to preserve case
  • Add test for reserved keyword handling in composite unique_key

Usage: specify reserved keywords with quotes in YAML config:
unique_key: ['field_id', '"time"']
updated_at: '"date"'

Add proper column quoting for Exasol snapshots when unique_key or
updated_at columns use reserved SQL keywords (TIME, DATE, USER, etc).

- Add exasol__quote_column helper macro that:
  - Passes through already-quoted columns ("time" → "time")
  - Uppercases and quotes unquoted columns (field_id → "FIELD_ID")
- Add exasol__build_scd_args to build properly quoted scd_id arguments
- Override snapshot_timestamp_strategy for proper quoting
- Add exasol__snapshot_check_strategy with proper quoting for check cols
- Add exasol__unique_key_fields macro for dbt_unique_key generation
- Remove | upper filter from snapshot_merge.sql to preserve case
- Add test for reserved keyword handling in composite unique_key

Usage: specify reserved keywords with quotes in YAML config:
  unique_key: ['field_id', '"time"']
  updated_at: '"date"'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

1 participant