aws-samples / dbt-glue

This repository contains the dbt-glue adapter
Apache License 2.0
102 stars 69 forks source link

Fix iceberg full refresh#247 #252

Closed sanga8 closed 11 months ago

sanga8 commented 1 year ago

Resolves #247

Description

Fixing full refresh with iceberg issue.

In the incremental.sql file, it was first checking if the relation was iceberg, instead of checking for full refresh. See athena connector implementation for reference.

We fix it by modifying the order of the condition, we first check if the user has used the full refresh flag (i.e. -f or --full-refresh).

To check if the user used the flag, we use the dbt core macro should_full_refresh() instead of the currently implemented full_refresh_mode variable. Since we don't need the full_refresh_mode variable anymore, we remove this variable from the code.

Once the full refresh condition is True, we check if it is an iceberg materialization. If yes, we first delete the table using glue__drop_relation macro in adapters.sql. Then, we write the table with the iceberg_write function, that will re-create the table from scratch since it does not exist anymore.

TLDR:

Checklist

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.