Skip to content

Commit c09ff98

Browse files
fix(volume): normalize path-like roots and error union typing
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent a82dba0 commit c09ff98

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/databricks/sql/backend/kernel/_errors.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def reraise_kernel_error(
152152
"diagnostic-info": getattr(exc, "diagnostic_info", None),
153153
}
154154
message = getattr(exc, "message", str(exc))
155+
new: Union[Error, FileNotFoundError]
155156
# Local missing files have no HTTP status; remote missing files carry 404.
156157
if (
157158
file_transfer

‎src/databricks/sql/backend/kernel/client.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import inspect
2424
import logging
25+
import os
2526
import re
2627
import threading
2728
import uuid
@@ -588,11 +589,11 @@ def execute_command(
588589
)
589590
stmt.set_sql(operation)
590591
allowed_paths = cursor.connection.staging_allowed_local_path
591-
if isinstance(allowed_paths, str):
592+
if isinstance(allowed_paths, (str, os.PathLike)):
592593
allowed_paths = [allowed_paths]
593594
set_paths = getattr(stmt, "set_staging_allowed_local_paths", None)
594595
if callable(set_paths):
595-
set_paths(allowed_paths or [])
596+
set_paths([os.fsdecode(path) for path in allowed_paths or []])
596597
elif _is_staging_statement(operation):
597598
raise NotSupportedError(
598599
"Volume transfers require a databricks-sql-kernel wheel "

‎tests/unit/test_kernel_client.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import sys
1717
import types
18+
from pathlib import Path
1819
from typing import Optional
1920
from unittest.mock import MagicMock
2021

@@ -810,6 +811,8 @@ def test_execute_command_forwards_row_limit(row_limit):
810811
[
811812
(None, []),
812813
("/tmp/files", ["/tmp/files"]),
814+
(Path("/tmp/files"), ["/tmp/files"]),
815+
([Path("/tmp/a"), Path("/tmp/b")], ["/tmp/a", "/tmp/b"]),
813816
(["/tmp/a", "/tmp/b"], ["/tmp/a", "/tmp/b"]),
814817
],
815818
)

0 commit comments

Comments
 (0)