duckdb / dbt-duckdb

dbt (http://getdbt.com) adapter for DuckDB (http://duckdb.org)
Apache License 2.0
924 stars 89 forks source link

Update Postgres Plugin for dbt-duckdb to Use ATTACH Syntax and Improve Compatibility #479

Closed Gexar closed 1 day ago

Gexar commented 1 day ago

Description:

This pull request updates the Postgres plugin for the dbt-duckdb adapter to align with the latest DuckDB PostgreSQL extension (ATTACH syntax) and introduces improvements to functionality, testing, and error handling.

Changes Made:

  1. Migration to ATTACH Syntax:

    • Replaced the deprecated CALL postgres_attach syntax with the new ATTACH command, returning the write-to-pg functionality.
    • Removed deprecated features like overwrite in favor of READ_ONLY.
  2. Enhanced Configuration:

    • Added support for configuring additional attach options and extension settings, ensuring compatibility with the latest DuckDB Postgres extension features.
  3. Improved Logging and Debugging:

    • Utilized AdapterLogger to provide clearer and more detailed error messages.
    • Enhanced traceability of plugin configuration and database attachment processes.
  4. Updated Unit Tests:

    • Refactored and extended test coverage to validate new functionality and edge cases:
      • Successful ATTACH with default and custom configurations.
      • Read/write operations in both read-only and read-write modes.
      • Handling of PostgreSQL arrays and error conditions for invalid configurations.
  5. Code Refactoring:

    • Improved code readability and maintainability by introducing helper methods (_set_extension_settings, _build_attach_statement).
    • Added type annotations for better developer experience and debugging.

Testing:

Impact:

Checklist:


Related Issues:
Unfortunately, due to this issue the testing has to be done outside the VSCode dev container.

478


Please review the changes and let me know if additional updates or refinements are needed. Thank you for your time and consideration!🚀

Gexar commented 23 hours ago

opened a new PR