Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbt run --select spark_test.sql --profile sparkprofile checks presence of "database" even in sources that are not referred in model #1178

Open
soham-dasgupta opened this issue Feb 22, 2025 · 2 comments

Comments

@soham-dasgupta
Copy link

soham-dasgupta commented Feb 22, 2025

dbt-core 1.8.9
spark 1.8.0

In addition to using Trino and Athena in dbt, we would like to use Spark and here are the relevant configurations

sources.yml

  - name: spark
    description: glue default database
    schema: default
    tables:
      - name: fact_customer_item_dly
        description: fact_customer_item_dly

profiles.yml

sparkprofile:
  target: dev
  outputs:
    dev:
      type: spark
      method: thrift
      host: localhost
      port: 10001
      schema: dev

spark_test.sql

{{ config(
    materialized='table',
    file_format='parquet'
) }}


select count(*) from {{ source('spark' ,'fact_customer_item_dly') }}

We now want to run the model spark_test.sql and invoke the below command

.venv/bin/dbt run --select spark_test.sql --profile sparkprofile

However we encounter the below error

Runtime Error
  Cannot set database in spark!

The model executes fine if I remove database from sources that are not related to Spark(Trino and Athena). This limits us in using Spark in addition to Trino and Athena, How can we solve this issue?

@soham-dasgupta
Copy link
Author

Issue created in dbt adapters repo dbt-labs/dbt-adapters#849

@data-blade
Copy link

we worked around (in our case having databricks/spark dual adapter) via

sources:
  - name: source_a
    database: "{{ none if target.type == 'spark' else 'catalog_a' }}"
    schema: "{{ 'catalog_a.schema_a' if target.type == 'spark' else 'schema_a' }}"

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

No branches or pull requests

2 participants