diff --git a/tests/fixtures/dbt_project/models/glaredb_data/join_csv_with_table.sql b/tests/fixtures/dbt_project/models/glaredb_data/join_csv_with_table.sql new file mode 100644 index 000000000..ddbf64c9a --- /dev/null +++ b/tests/fixtures/dbt_project/models/glaredb_data/join_csv_with_table.sql @@ -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 \ No newline at end of file diff --git a/tests/fixtures/dbt_project/profiles.yml b/tests/fixtures/dbt_project/profiles.yml index a806ed851..502894bb5 100644 --- a/tests/fixtures/dbt_project/profiles.yml +++ b/tests/fixtures/dbt_project/profiles.yml @@ -9,4 +9,13 @@ glaredb_dbt_test: threads: 1 type: postgres user: "{{ env_var('DBT_USER') }}" + cloud: + dbname: default + host: o_PRocU0j.proxy.glaredb.com + pass: glaredb_pw_SFZmILqgkZgsJWPUlnEF1KUts6b1 + port: 6543 + schema: public + threads: 1 + type: postgres + user: 6AhiEN7GQDmo target: test_target diff --git a/tests/fixtures/glaredb.py b/tests/fixtures/glaredb.py index 65aaf9ef4..c484991ee 100644 --- a/tests/fixtures/glaredb.py +++ b/tests/fixtures/glaredb.py @@ -26,7 +26,6 @@ def glaredb_path() -> list[pathlib.Path]: def binary_path(glaredb_path: list[pathlib.Path]) -> pathlib.Path: return glaredb_path[0] if glaredb_path[0].exists() else glaredb_path[1] - @pytest.fixture def glaredb_connection( binary_path: list[pathlib.Path], diff --git a/tests/test_dbt.py b/tests/test_dbt.py index fc37f2cd4..bbf066830 100644 --- a/tests/test_dbt.py +++ b/tests/test_dbt.py @@ -106,3 +106,41 @@ def test_dbt_glaredb_external_postgres( result: list = curr.fetchone()[0] assert result == 5 + +def test_dbt_join_csv_with_table( + glaredb_connection: psycopg2.extensions.connection, + dbt_project_path: pathlib.Path, +): + model_name = "join_csv_with_table" + + 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("GLAREDB_PORT", str(glaredb_connection.info.port)), + 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