Skip to content

Commit

Permalink
fix sql client tests again... :)
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Oct 7, 2024
1 parent 41926ae commit 9b8437a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/load/filesystem/test_sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ def _run_dataset_checks(
destination_config.bucket_url.startswith("s3")
or destination_config.bucket_url.startswith("az")
or destination_config.bucket_url.startswith("abfss")
or destination_config.bucket_url.startswith("gs")
)

unsupported_persistent_secrets = destination_config.bucket_url.startswith("gs")

@dlt.source()
def source():
@dlt.resource(
Expand Down Expand Up @@ -77,7 +78,7 @@ def double_items():
pipeline.destination = alternate_access_pipeline.destination

import duckdb
from duckdb import HTTPException, IOException
from duckdb import HTTPException, IOException, InvalidInputException
from dlt.destinations.impl.filesystem.sql_client import (
FilesystemSqlClient,
DuckDbCredentials,
Expand Down Expand Up @@ -159,7 +160,7 @@ def _fs_sql_client_for_external_db(
external_db.close()

# in case we are not connecting to a bucket, views should still be here after connection reopen
if not needs_persistent_secrets:
if not needs_persistent_secrets and not unsupported_persistent_secrets:
external_db = _external_duckdb_connection()
assert (
len(external_db.sql("SELECT * FROM second.referenced_items").fetchall())
Expand All @@ -170,13 +171,17 @@ def _fs_sql_client_for_external_db(

# in other cases secrets are not available and this should fail
external_db = _external_duckdb_connection()
with pytest.raises((HTTPException, IOException)):
with pytest.raises((HTTPException, IOException, InvalidInputException)):
assert (
len(external_db.sql("SELECT * FROM second.referenced_items").fetchall())
== total_records
)
external_db.close()

# gs does not support persistent secrest, so we can't do further checks
if unsupported_persistent_secrets:
return

# create secret
external_db = _external_duckdb_connection()
fs_sql_client = _fs_sql_client_for_external_db(external_db)
Expand All @@ -199,7 +204,7 @@ def _fs_sql_client_for_external_db(

# fails again
external_db = _external_duckdb_connection()
with pytest.raises((HTTPException, IOException)):
with pytest.raises((HTTPException, IOException, InvalidInputException)):
assert (
len(external_db.sql("SELECT * FROM second.referenced_items").fetchall())
== total_records
Expand All @@ -213,7 +218,7 @@ def _fs_sql_client_for_external_db(
destinations_configs(
local_filesystem_configs=True,
all_buckets_filesystem_configs=True,
bucket_exclude=[SFTP_BUCKET],
bucket_exclude=[SFTP_BUCKET, MEMORY_BUCKET],
), # TODO: make SFTP work
ids=lambda x: x.name,
)
Expand Down

0 comments on commit 9b8437a

Please sign in to comment.