Skip to content

add dbt integration tests #812

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

add dbt integration tests #812

wants to merge 3 commits into from

Conversation

osmazur
Copy link

@osmazur osmazur commented May 15, 2025

Add dbt integration tests, packages edition:

  • dbt snowplow
  • dbt utils
    Configured to run against snowflake or embucket.
    Structure:
  • profiles.yml, is a file to set the connection to the dbt.
  • repos.yml, contain git links to the dbt packages available to run integration tests
  • repos_full_list.yml, contain all the packages with the integration tests
  • requiremets.txt
  • run_test.sh, bash file configured to run integration tests (setup dbt, env, load the package and run dbt commands)
  • upload.py and Web_Analytics_sample_events.csv, files to create the embucket database
  • packages folder, stores the logs in log/<package_name>/* directory. Not pushed into the repo, you will see it locally after the run.
  • logs folder, stores the cloned package in /packages/<package_name> directory. Not pushed into the repo, you will see it locally after the run.

@osmazur osmazur requested a review from andheroe May 15, 2025 07:08
@osmazur osmazur force-pushed the add-dbt-integration-tests branch from f536d12 to 314ffcc Compare May 15, 2025 07:30
@osmazur osmazur force-pushed the add-dbt-integration-tests branch from 314ffcc to 12c641b Compare May 15, 2025 08:34
response.raise_for_status()

## SCHEMA
query = f"CREATE SCHEMA IF NOT EXISTS {catalog}.{schema}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we technically don't have this API easily working (since UI now requires some other attributes like worksheet_id and authentication token), here is the code I used to create schema that might be better fit here

def create_table(database, schema, table, query):
    import snowflake.connector

    USER = os.getenv("SNOWFLAKE_USER", "xxx")
    PASSWORD = os.getenv("SNOWFLAKE_PASSWORD", "yyy")
    ACCOUNT = os.getenv("SNOWFLAKE_ACCOUNT", "acc")
    DATABASE = os.getenv("SNOWFLAKE_DATABASE", database)
    SCHEMA = os.getenv("SNOWFLAKE_SCHEMA", schema)
    WAREHOUSE = os.getenv("SNOWFLAKE_WAREHOUSE", "")

    con = snowflake.connector.connect(
        host=os.getenv("SNOWFLAKE_HOST", "localhost"),
        port=os.getenv("SNOWFLAKE_PORT", 3000),
        protocol=os.getenv("SNOWFLAKE_PROTOCOL", "http"),
        user=USER,
        password=PASSWORD,
        account=ACCOUNT,
        warehouse=WAREHOUSE,
        database=DATABASE,
        schema=SCHEMA,
        session_parameters={
            "QUERY_TAG": "dbt-testing",
        },
    )

    cursor = con.cursor()
    cursor.execute(f"CREATE SCHEMA IF NOT EXISTS {database}.{schema}")
    cursor.execute(query)

@rampage644
Copy link
Contributor

@osmazur Feel free to mark conversation as resolved and merge

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.

4 participants