Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion pysus/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,11 @@ async def query(

if client:
prefix = f"public/data/{client.lower()}/"
files = [f for f in files if str(f.path).startswith(prefix)]
files = [
f
for f in files
if str(f.path).replace("\\", "/").startswith(prefix)
]

if not as_dataframe:
return files
Expand Down
10 changes: 8 additions & 2 deletions pysus/tests/api/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ async def test_query_no_dataset_iterates_all(self, test_db_path):

@pytest.mark.asyncio
async def test_query_with_client_filter(self, test_db_path):
from pathlib import PureWindowsPath
from unittest.mock import AsyncMock, MagicMock

from pysus.api.ducklake.client import DuckLake
Expand All @@ -529,15 +530,20 @@ async def test_query_with_client_filter(self, test_db_path):
mock_file2 = MagicMock()
mock_file2.path = "public/data/dadosgov/otherfile"

ds.query = AsyncMock(return_value=[mock_file1, mock_file2])
# DuckLake may return WindowsPath instances on Windows. The client
# filter must compare normalized POSIX paths so FTP files are retained.
mock_file3 = MagicMock()
mock_file3.path = PureWindowsPath("public/data/ftp/windows-file")

ds.query = AsyncMock(return_value=[mock_file1, mock_file2, mock_file3])
mock_ducklake.datasets = AsyncMock(return_value=[ds])

client._ducklake = mock_ducklake
client._attach_client_catalog = MagicMock()

result = await client.query(dataset="sinan", client=FTP)

assert result == [mock_file1]
assert result == [mock_file1, mock_file3]

await client.__aexit__(None, None, None)

Expand Down