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

chore: add dbt read_csv test #2732

Merged
merged 9 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Collaborator

Choose a reason for hiding this comment

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

this file name doesn't look right?

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ config(materialized='view') }}

select *
from dbt_test
JOIN read_csv('https://github.com/GlareDB/glaredb/raw/main/testdata/csv/userdata1.csv') csv
ON dbt_test.amount = csv.id
35 changes: 35 additions & 0 deletions tests/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,38 @@ def test_dbt_glaredb_external_postgres(
result: list = curr.fetchone()[0]

assert result == 5

def test_dbt_read_excel_and_csv(
glaredb_connection: psycopg2.extensions.connection,
dbt_project_path: pathlib.Path,
):
model_name = "read_excel_and_csv"

with glaredb_connection.cursor() as curr:
curr.execute("create table dbt_test (amount int)")
curr.execute(
"INSERT INTO dbt_test (amount) VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9)"
)
curr.execute("SELECT * FROM public.dbt_test")
a = curr.fetchall()

with tests.tools.env("DBT_USER", glaredb_connection.info.user):
res: dbtRunnerResult = dbtRunner().invoke(
[
"run",
"--project-dir",
dbt_project_path,
"--profiles-dir",
dbt_project_path,
"-m",
model_name,
]
)

assert res.success is True

with glaredb_connection.cursor() as curr:
curr.execute(f"select count(*) from {model_name}")
result: list = curr.fetchone()[0]

assert result == 9