aws-samples / aws-samples/dbt-glue

Enable database property when using catalogs

Open
#623 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
147
Forks
96
Avg merge
7h 4m
Merged PRs (30d)
5

Description

### Describe the feature
Allow `database` to be enabled in the `SparkIncludePolicy` for catalog backed Spark configurations. This would enable using the `--defer` flag across different iceberg catalogs. I am specifically using S3 tables, but should apply to other catalogs as well.

### Describe alternatives you've considered
I have customized a `generate_schema_name` macro that prepends the catalog identifier, but this breaks the `get_relation` implementation, at least for S3 tables, which uses this value as the "namespace".

### Additional context
I use different catalogs to separate environments and my data landing zone from my transformation layer. I achieve this by defining different catalogs, like `raw` for the landing zone and a `dev_mrt`, `qa_mrt`, and `prd_mrt` for the different environments.

To support this, my dbt profile include config values like:

```
--conf spark.sql.catalog.raw=org.apache.iceberg.spark.SparkCatalog
--conf spark.sql.catalog.raw.catalog-impl=software.amazon.s3tables.iceberg.S3TablesCatalog
--conf spark.sql.catalog.raw.warehouse=arn:aws:s3tables:us-east-1:1234567890:bucket/raw-s3tables

--conf spark.sql.catalog.dev_mrt=org.apache.iceberg.spark.SparkCatalog
--conf spark.sql.catalog.dev_mrt.catalog-impl=software.amazon.s3tables.iceberg.S3TablesCatalog
--conf spark.sql.catalog.dev_mrt.warehouse=arn:aws:s3tables:us-east-1:1234567890:bucket/dev-mrt-s3tables

--conf spark.sql.catalog.qa_mrt=org.apache.iceberg.spark.SparkCatalog
--conf spark.sql.catalog.qa_mrt.catalog-impl=software.amazon.s3tables.iceberg.S3TablesCatalog
--conf spark.sql.catalog.qa_mrt.warehouse=arn:aws:s3tables:us-east-1:1234567890:bucket/qa-mrt-s3tables
```

### Who will this benefit?
Anyone who is using catalogs to separate environments and looking to use the `--defer` flag.

### Are you interested in contributing this feature?
Yes, I would be interested in helping. In a local copy I was able to achieve the desired functionality via changes in [this commit](https://github.com/aws-samples/dbt-glue/commit/d419e17553227db1489e47cc5682ba5c30d5822f).

I suspect that this would not work for other kinds of implementations and that databases are disabled for a good reason. If there would at least be a way that an environment variable could be configured or some conditional logic to see if a catalog is being used to allow use of the `database` property. If there is a preferred approach that someone can guide me to, then I would be interested in making a contribution.

Contributor guide

Open the contributing guide

Research direction

Start with SparkIncludePolicy and the linked commit, then trace how database is currently handled for catalog-backed Spark configurations. Review the interaction between generate_schema_name and get_relation, and validate that enabling database supports --defer across catalogs without breaking namespace resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, spark
Domain
data-engineering, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.